> # R commands go here.
> # You can adjust fig.height, and fig.width to make graphs look better.
> # For example, for a small graph, try {r fig.width=4, fig.height=4};
> # for a graph with two side-by-side panels, try {r fig.height=4}.
- Intersperse R code chunks with explanatory text as needed.
- Press the Knit button in the toolbar to process the .Rmd file into an .html (or .pdf or .docx) file.
- For more information on using R Markdown in RStudio click on “Help > Markdown Quick Reference”, “Help > Cheatsheets > R Markdown Cheat Sheet”, or “Help > Cheatsheets > R Markdown Reference Guide”.
- Shortcut to Insert R chunk
- Windows users:Ctrl+Alt+I
- Mac users: Command+Option+I
Calculate 444
> 4^4^4
[1] 1.340781e+154
Calculate Exp(4/8)
> exp(4/8)
[1] 1.648721
Assign a value of 10 to an object called X
> x=10
Assign a vector of 1 to 5 to an object called y
> y=c(1, 2, 3, 4, 5)
Calculate the result of log(x*y)
> log(x*y)
[1] 2.302585 2.995732 3.401197 3.688879 3.912023
Store the result of log(x*y) to an object called z
> z=log(x*y)
Test if the last element of object y is greater than 5
> y[5]>5
[1] FALSE
Identify the structure of x, y, and z
> str(x)
num 10
Load data covid19 at Bexar county, and view the data
> library(haven)
> bexar_covid <- read_dta('C:/Users/codar/OneDrive/Documents/R/Fall2020 - 7273/bexar-covid.dta')
> View(bexar_covid)
What’s the size of this data frame? How many rows, and how many columns?
> dim(bexar_covid)
[1] 179 67
> length(bexar_covid)
[1] 67