R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

getwd()
## [1] "C:/Users/Jerome/Documents/0000_Work_Files/0000_Coursera/Statistics_with_R_Specialization/Course_1_Probability_&_Data"
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.2
## 
## 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
library(ggplot2)
library(statsr)
## Warning: package 'statsr' was built under R version 4.0.3
library(shiny)
## Warning: package 'shiny' was built under R version 4.0.2
library(devtools)
## Warning: package 'devtools' was built under R version 4.0.2
## Loading required package: usethis
## Warning: package 'usethis' was built under R version 4.0.2
data("arbuthnot")
View(arbuthnot)
dim(arbuthnot)
## [1] 82  3
arbuthnot$boys
##  [1] 5218 4858 4422 4994 5158 5035 5106 4917 4703 5359 5366 5518 5470 5460 4793
## [16] 4107 4047 3768 3796 3363 3079 2890 3231 3220 3196 3441 3655 3668 3396 3157
## [31] 3209 3724 4748 5216 5411 6041 5114 4678 5616 6073 6506 6278 6449 6443 6073
## [46] 6113 6058 6552 6423 6568 6247 6548 6822 6909 7577 7575 7484 7575 7737 7487
## [61] 7604 7909 7662 7602 7676 6985 7263 7632 8062 8426 7911 7578 8102 8031 7765
## [76] 6113 8366 7952 8379 8239 7840 7640
ggplot (data = arbuthnot, aes(x=year, y = girls)) +
  geom_point()

ggplot (data = arbuthnot, aes(x=year, y = boys)) +
  geom_point()

data(present)
5218+4683
## [1] 9901
arbuthnot$boys+arbuthnot$girls
##  [1]  9901  9315  8524  9584  9997  9855 10034  9522  9160 10311 10150 10850
## [13] 10670 10370  9410  8104  7966  7163  7332  6544  5825  5612  6071  6128
## [25]  6155  6620  7004  7050  6685  6170  5990  6971  8855 10019 10292 11722
## [37]  9972  8997 10938 11633 12335 11997 12510 12563 11895 11851 11775 12399
## [49] 12626 12601 12288 12847 13355 13653 14735 14702 14730 14694 14951 14588
## [61] 14771 15211 15054 14918 15159 13632 13976 14861 15829 16052 15363 14639
## [73] 15616 15687 15448 11851 16145 15369 16066 15862 15220 14928
arbuthnot <- arbuthnot %>%
  mutate(total = boys + girls)
ggplot(data = arbuthnot, aes(x = year, y = total)) +
  geom_line() +
  geom_point()

ggplot(data = arbuthnot, aes(x = year, y = boys/total)) +
  geom_line() +
  geom_point()

arbuthnot <- arbuthnot %>%
  mutate(boy_percent = boys / total)
ggplot(data = arbuthnot, aes(x = year, y = boy_percent)) +
  geom_line() +
  geom_point()

arbuthnot <- arbuthnot %>% 
  mutate (more_boys = boys > girls)
arbuthnot_rja <- arbuthnot
 write.csv (arbuthnot_rja, file = "arbuthnot_rja.csv", row.names = FALSE)
range(present$year)
## [1] 1940 2013
present <- present %>%
  mutate(total = boys + girls) %>%
mutate (percent_boys = boys / total) %>%
mutate (more_boys = boys > girls)
ggplot(data = present, aes(x = year, y = percent_boys)) +
  geom_line() +
  geom_point()

present_rja <- present
 write.csv (present_rja, file = "presentt_rja.csv", row.names = FALSE)