packages <- c("gapminder", "dplyr", "ggplot2")
lapply(packages, library, character.only = TRUE)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## [[1]]
## [1] "gapminder" "stats"     "graphics"  "grDevices" "utils"     "datasets" 
## [7] "methods"   "base"     
## 
## [[2]]
## [1] "dplyr"     "gapminder" "stats"     "graphics"  "grDevices" "utils"    
## [7] "datasets"  "methods"   "base"     
## 
## [[3]]
##  [1] "ggplot2"   "dplyr"     "gapminder" "stats"     "graphics"  "grDevices"
##  [7] "utils"     "datasets"  "methods"   "base"
data(gapminder)

gapminder_2007 <- gapminder %>% filter(year == 2007)

gapminder_2007 <- gapminder_2007 %>%
  arrange(gdpPercap)

ggplot(gapminder_2007, aes(x = reorder(country, gdpPercap), y = gdpPercap)) +
  geom_bar(stat = "identity", fill = "blue", color = "black", alpha =1) +
  labs(title = "GDP per Capita of Countries in 2007",
       x = "Country",
       y = "GDP per Capita") + 
  theme(axis.text.x = element_blank(),
        axis.ticks.x = element_blank())

summary(gapminder_2007$gdpPercap)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   277.6  1624.8  6124.4 11680.1 18008.8 49357.2

The mean GDP per capita in 2007 is 11680.1. This value represents the average economic output per person for all countries included in the dataset for the year 2007.

print("I did it!")
## [1] "I did it!"