Click here to download the Rmd file: week1-intro-RMarkdown.Rmd
print("This is Thursday.")
[1] "This is Thursday."
Tools --> Global Options -->
- Uncheck "Restore .RData into workspace at startup".
- Set "Save workspace to .RData on exit" to "Never".
- (Optional) R Markdown --> Set "Show output preview in" to "Viewer Pane".
Use Project
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:
Note: R is case sensitive. So
Cars
andcars
are different.
summary(cars[-(1:4), ])
title
, author
, date
,
output
include
echo
eval
results = 'hide'
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.
tweetrmd::include_tweet("https://twitter.com/visnut/status/1248087845589274624")
Students struggle with install vs library every semester, and keep including their install code in the RMarkdown report. Hope this meme might help in the future #rstats pic.twitter.com/I8xg053y0x
— Dr Di Cook (@visnut) April 9, 2020
Check out https://rladiessydney.org/courses/ryouwithme/01-basicbasics-2/
# Install the tidyverse "meta" package
# install.packages("tidyverse")
# Install the lme4 package
# install.packages("lme4")
Tip 1: Try the (PC) Ctrl + Alt + I/(Mac) Cmd + Option + I shortcut for a new code chunk
Tip 2: Use Tab for code completeion
Tip 3: Use Ctrl + Enter/(Mac) Cmd + Return for running a line of R code
Tip 4: Set
message = FALSE
to suppress messages in loading packages
# Load tidyverse
# Load lme4
# Load SleepStudy
# Extract one column
# Extract column by index (same as last line)
# Extract two rows
# Compute the mean and sd, and chain them together
# Correlation matrix with psych::pairs.panel()
# Find out what a function does (use `?function_name`, e.g., `?pairs.panel`)
From RStudio, click Help
–>
Markdown Quick Reference
This is italic
Inline: The correlation between \(a = b + c + \tau\)
Display:
\[a = b + c + \tau\]
More detailed cheatsheet: https://rmarkdown.rstudio.com/lesson-15.HTML
Copy the following LaTex equation to below:
A_1 = \pi r^2
. How does this say about writing Greek
letters and subscripts/superscripts? \[[Insert equation here]\]
Install and then load the modelsummary
package, and
run the following. You’ll need to remove eval = FALSE
so
that it runs. Find out what this code chunk does.
Run the following. You’ll need to remove
eval = FALSE
so that it runs. Find out what this code chunk
does.
Add a code chunk below to show the output of running
sessionInfo()
, which prints out the session information of
your computer. Make the code chunk to show only the output, but not the
code.
Knit the document to HTML, PDF, and Word. If you run into an error when knitting to any one of the formats, record the error message. Which format do you prefer?
Go to the top of this Rmd file, and change the line inside YAML
html_document: default
to
html_document:
toc: TRUE
Knit the document again. What does it do?
Submit the knitted document to Blackboard in your preferred format (HTML, PDF, or WORD)