library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.1     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
    library(gapminder)
## Warning: package 'gapminder' was built under R version 4.1.2
    data(gapminder)
gapminder
## # A tibble: 1,704 x 6
##    country     continent  year lifeExp      pop gdpPercap
##    <fct>       <fct>     <int>   <dbl>    <int>     <dbl>
##  1 Afghanistan Asia       1952    28.8  8425333      779.
##  2 Afghanistan Asia       1957    30.3  9240934      821.
##  3 Afghanistan Asia       1962    32.0 10267083      853.
##  4 Afghanistan Asia       1967    34.0 11537966      836.
##  5 Afghanistan Asia       1972    36.1 13079460      740.
##  6 Afghanistan Asia       1977    38.4 14880372      786.
##  7 Afghanistan Asia       1982    39.9 12881816      978.
##  8 Afghanistan Asia       1987    40.8 13867957      852.
##  9 Afghanistan Asia       1992    41.7 16317921      649.
## 10 Afghanistan Asia       1997    41.8 22227415      635.
## # ... with 1,694 more rows
#population VS time of germany
gapminder_ger<-filter(gapminder, country == 'Germany')
ggplot(gapminder_ger) + geom_point(mapping = aes(x = pop, y = year))

ggplot(gapminder_ger) + geom_line(mapping = aes(x = pop, y = year))

#Create same plots for your own country.
gapminder_Ind<-filter(gapminder, country == 'India')
ggplot(gapminder_Ind) + geom_point(mapping = aes(x = pop, y = year))

ggplot(gapminder_Ind) + geom_line(mapping = aes(x = pop, y = year))

#Make a histogram of for life expectancy values for year 2007. Do not forget that you need to subset your dataset
gapminder_2007 <- gapminder %>%
 filter(year == 2007)
p = ggplot(gapminder_2007, aes(x=lifeExp, fill=year)) +
 geom_histogram(position="identity", colour="grey40", alpha=0.2, bins = 10)
p

#Create a facets of histograms life expectancy values by year
p = ggplot(gapminder, aes(x=lifeExp, fill=country)) +
 geom_histogram(position="identity", colour="grey40", alpha=0.2, bins = 10)+
facet_grid(. ~year )
p

#Create a line plot of life expectancy values for the countries. In the aesthetics, you need to set x,y and by
ggplot(gapminder) +
 geom_line(aes(x = lifeExp, y = country)) +
 scale_x_log10()

#Create a line plot of life expectancy values for the countries. Set the color for the continent values In the aesthetics, you need to set x,y, by and color.
ggplot(data = gapminder) +
 geom_line(mapping = aes(x =lifeExp , y =  country, color = continent, size = pop)) +
 scale_x_log10()

#Create a line plot of life expectancy values for the countries. create the facets for the continent values
ggplot(gapminder_2007) +
 geom_line(aes(x = lifeExp, y = country, color = year, size = pop)) +
 scale_x_log10() +
 facet_wrap(~ continent)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?