Population test

Author

Ash

setwd("/Users/asherscott/Desktop/Data 110")
Pop1<- read.csv("Pop.csv")
summary(Pop1)
     number            age            gender            population    
 Min.   :  1.00   Min.   :  1.00   Length:200         Min.   :0.2293  
 1st Qu.: 50.75   1st Qu.: 25.75   Class :character   1st Qu.:0.3120  
 Median :100.50   Median : 50.50   Mode  :character   Median :0.3755  
 Mean   :100.50   Mean   : 50.50                      Mean   :0.5000  
 3rd Qu.:150.25   3rd Qu.: 75.25                      3rd Qu.:0.5124  
 Max.   :200.00   Max.   :100.00                      Max.   :2.8409  
    X             X.1            X.2         
 Mode:logical   Mode:logical   Mode:logical  
 NA's:200       NA's:200       NA's:200      
                                             
                                             
                                             
                                             
library(ggplot2)
library(dplyr)

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
Pop1 %>% mutate( 
    population = ifelse(gender=="M", population*(-1), 
                        population*1))%>% 
    ggplot(aes(x = age,y = population, fill=gender)) +  
    geom_bar(stat = "identity") + 
    coord_flip()+ 
    scale_y_continuous(limits = c(-4,4),  
                       breaks = seq(-4, 4, by = 2))+ 
   labs(title = "Graph", x = "Age", 
        y = "Population(in millions)")