Language: R - install: http://cran.r-project.org/
Integrated development environment: RStudio - install: http://www.rstudio.com/
The panel in the upper right contains your workspace as well as a history of the commands that you’ve previously entered.
Any plots that you generate will show up in the viewer tabl of the panel in the lower right corner.
This is also where you can access your files, view/install packages, view help.
If you haven’t yet done so, create a folder for this course, and within this directory create another directory called application exercises.
In the Files pane of your RStudio window, browse to this directory.
Click on More, and then Set as working directory.
This action will prompt a line of code in your Console using the setwd
function.
setwd([some_path]/Sta112FS/application_exercises)
RStudio allows you to complete certain routine tasks using point-and-click, but will often also show you the R code associated with that action.
Say someone in your family is pregnant, and it’s too early to find out the sex of the baby. What is the probability she is pregnant with a girl?
What type of data would you use to answer the question what percent of births are girls?
Dr. John Arbuthnot, an 18th century physician, writer, and mathematician. He was interested in the ratio of newborn boys to newborn girls, so he gathered the baptism records for children born in London for every year from 1629 to 1710.
Load the data frame:
source("http://www.openintro.org/stat/data/arbuthnot.R")
View the dimensions of this data frame:
dim(arbuthnot)
## [1] 82 3
View the dimensions of this data frame:
names(arbuthnot)
## [1] "year" "boys" "girls"
To open a new R Markdown document document click on the green + button on the top left corner of your RStudio window, and then choose R Markdown. Choose Document, and then fill in the Title and Author information. Choose HTML as the output format.
In this document R code goes in “chunks”. A quick reference guide for the markdown language can be accessed via the ? button.
Independent environment than the console – all steps of the data analysis must be included for the file to compile properly (starting with loading the dataset).