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:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

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(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.4     v stringr 1.4.0
## v tidyr   1.1.2     v forcats 0.5.0
## v readr   1.4.0
## Warning: package 'tibble' was built under R version 4.0.3
## Warning: package 'tidyr' was built under R version 4.0.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
getwd()
## [1] "C:/Users/Jerome/Documents/0000_Work_Files/0000_Coursera/Statistics_with_R_Specialization/Course_1_Probability_&_Data/Lab2"
Raw_Data_Test_Table_in_R <- read.csv((file = 'Raw_Data_Test_Table_in_R.csv'))
table(Raw_Data_Test_Table_in_R$Age, Raw_Data_Test_Table_in_R$Salary)
##     
##      20000 21000 34000 34765 45999 54000 56762 58765 67000 81234 83678 89000
##   21     0     1     0     0     0     0     0     0     0     0     0     0
##   25     1     0     0     0     0     0     0     0     0     0     0     0
##   30     0     0     1     0     0     0     0     0     0     0     0     0
##   32     0     0     0     0     0     1     0     0     0     0     0     0
##   37     0     0     0     0     0     0     0     0     1     0     0     0
##   39     0     0     0     0     0     0     0     0     0     1     0     0
##   41     0     0     0     0     1     0     0     0     0     0     0     0
##   43     0     0     0     0     0     0     0     1     0     0     0     0
##   45     0     0     0     0     0     0     1     0     0     0     0     0
##   48     0     0     0     1     0     0     0     0     0     0     0     0
##   52     0     0     0     0     0     0     0     0     0     0     0     1
##   57     0     0     0     0     0     0     0     0     0     0     0     0
##   58     0     0     0     0     0     0     0     0     0     0     1     0
##   63     0     0     0     0     0     0     0     0     0     0     0     0
##   66     0     0     0     0     0     0     0     0     0     0     0     0
##     
##      93000 109876 123653
##   21     0      0      0
##   25     0      0      0
##   30     0      0      0
##   32     0      0      0
##   37     0      0      0
##   39     0      0      0
##   41     0      0      0
##   43     0      0      0
##   45     0      0      0
##   48     0      0      0
##   52     0      0      0
##   57     1      0      0
##   58     0      0      0
##   63     0      1      0
##   66     0      0      1
table(Raw_Data_Test_Table_in_R$Height, Raw_Data_Test_Table_in_R$Weight)
##     
##      135 147 149 154 163 174 175 181 182 184 190 195 200 225
##   58   0   0   0   0   0   1   0   0   0   0   0   0   0   0
##   60   1   0   0   0   0   0   0   0   0   0   0   0   0   0
##   64   0   1   0   0   0   0   0   0   0   0   0   0   0   0
##   65   0   0   1   0   1   0   0   0   0   0   0   0   0   0
##   67   0   0   0   0   0   0   0   0   1   0   0   0   0   0
##   68   0   0   0   1   0   0   0   0   0   0   0   0   0   0
##   70   0   0   0   0   0   0   0   0   0   1   0   0   0   0
##   71   0   0   0   0   0   0   0   1   0   0   0   0   0   0
##   72   0   0   0   0   1   0   0   0   0   0   0   0   0   0
##   75   0   0   0   0   0   0   1   0   0   0   1   0   0   0
##   76   0   0   0   0   0   0   0   0   0   0   0   1   0   0
##   78   0   0   0   0   0   0   0   0   0   0   0   0   0   1
##   80   0   0   0   0   0   0   0   0   0   0   0   0   1   0
### So in R, when you type table(), the 1st variable is the row, the 2nd one is the column. I assumed that was the case, but this confirms it.