1. Please download and install R at https://cran.r-project.org/
2. Please download and install RStudio at https://www.rstudio.com/
3. Please go to http://rpubs.com/ and register for an account.
4. Open RStudio.
1. On the panel on the right please select the Packages tab.
2. Under that tab select the Install tab.
3. In the packages tab type ‘knitr’. Don’t use quotation marks.
4. After it is installed you should see it under the Packages tab. Please select it by clicking the checkbox.
5. Under File select New file then R Markdown.
6. In the Title Tab put Assign 1. In the Author Tab put your name.
7. Make sure HTML is selected as the Default Output Format and then click ok. Also make sure Document is highlighted.
8. Under File select Save As. Give it a name and save it anywhere you like. Note it will have a .Rmd extension.
9. In the main panel of your RStudio display click Knit HTML.
10. In 2-3 seconds a window should pop up.
11. At the top of that window select publish. This takes you to the rpubs website. Please login with the login you recently created and publish your website.
12. You should now see your website that should look exactly like this page your are looking at now except it won’t have these instructions you are currently reading. A good amount of your homework will be done using RMarkdown. So you will just email your website URL to the appropriate grader to turn in your homework.
1. Go back into RStudio and open your RMarkdown file.
2. Cars is a dataset built into R. We can use it to get familiar with some typical R commands. You can see that summary(cars) gives a handful of statistics of the cars dataset. Directly under the summary(cars) line type head(cars) and directly under that type tail(cars). This will give you the first few and last few lines of the cars dataset.
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
head(cars)
## speed dist
## 1 4 2
## 2 4 10
## 3 7 4
## 4 7 22
## 5 8 16
## 6 9 10
tail(cars)
## speed dist
## 45 23 54
## 46 24 70
## 47 24 92
## 48 24 93
## 49 24 120
## 50 25 85
3. The section of your code that has three backticks and {r} is where your R code goes. These are called Chunks.
4. To make a new R Chunk click the Chunks tab in the upper right. Then select Insert Chunk.
5. In between the these two lines that have the backticks type names(iris). Note iris is another dataset built into R and the names command gives us the names of all of the variables in the dataset.
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:
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.