R Markdown

This document is to show exaclty the form of the markdown and how someone who is unfamiliar with the language of R and the format of Markdowns

Commenting in R

# Every script in R should have commenting at the top. The first couple of lines in a script should contain similar information:

Beginning a Script with Comments

#Nick Vohra
#August 2nd, 2019
#Lab of Kevin Houston

# Importation and analyzation of data compiled thorugh multiple patient visits. The variables of interst are X, Y and Z. Statistical analysis in the form of TEST1, TEST2 and TEST3. 

#####Section 1##### <- this syntax creates a searchable chunk of code
#     Code     #

Practicing with mtcars

#We covered the packages part of RStudio (bottom left)
#We click the package to 'activate' or load it
#Its up to you to decide how you want to view the data. 

#Lets start with a view of the data structure but looking at the first 6 rows 
head(mtcars)

Pick the data from the set.

# Lets say we are interested in weight and mpg, we need to extract the data and assign them a NAME that is, an object. 

#We type somethign like --- weight = mtcars$wt and therefore the term weight is given to the data

weight = mtcars$wt
miles_per_gallon = mtcars$mpg

#the ' $ ' symbol means that you want to break up the data set that preceds it. The above two lines of code show it well. 

#Those lines create the object and they will be invoked later. Lets test out some summary 

Running summary stats on the data

#We use the summary() to get the summary stats of thse data columns
summary(weight)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.513   2.581   3.325   3.217   3.610   5.424
summary(miles_per_gallon)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.40   15.43   19.20   20.09   22.80   33.90
#R knows that these two arguments becasue we defined them earlier

Plotting the argumets against each other

#We want to plot these datga sets against each other. In this markdown we will keep things as easy as pooible adn simply use the plot() function

plot(weight, miles_per_gallon)

# R allows us to give the plot custom axes, titles, subtitles, trendlines etc. But that is for another tim :)

End