Can replace ‘html_document’ with ‘pdf_document’ in the .Rmd (Rmarkdown) file above manually to generate the output in your preferred format. However, I would strongly suggest using HTML format initially as the setup is likely to reduce math symbol issues if you do not have Latex installed locally.
Also, make sure to change the settings of the document based on your preferences by clicking on the setting symbol (next to Knit button) -> Output Options -> Include table of contents/Output Format…
Use visual mode instead of the source code (if you are new) to make your like simple.
This contains the link to R Markdown Cheatsheet. Please read it - it has everything you need to know about R Markdown for our course.
This is my first attempt - normal text.
This is my second attempt - bold.
This is my third attempt - italicize.
# Clear the workspace
rm(list = ls()) # Clear environment
gc() # Clear unused memory
## used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
## Ncells 551532 29.5 1225678 65.5 NA 700254 37.4
## Vcells 1022815 7.9 8388608 64.0 49152 1963353 15.0
cat("\f") # Clear the console
par(mfrow=c(1,1)) # Clear plots. Can use dev.off()
Run a chunk with eval=FALSE now, thus no R output printed but commands still printed.
?factorial
factorial(5)
5*4*3*2*1
df<- 5
Note df object not created, as code chunk is skipped/not evaluated.
?factorial
factorial(5)
## [1] 120
5*4*3*2*1
## [1] 120
factorial(0)
## [1] 1
?choose
choose(n = 3,k = 3) # combinations
## [1] 1
choose(3,0) # only 1 way to make this selection
## [1] 1
Run the same chunk above with echo=False. Make sure to change the r code chunk name. Command names printed as eval=TRUE by default. Make both of them false and nobody can see them in the output and you have hidden code in your Markdown file.
Can print graphs in your file too.
plot(iris[1:4], col=iris$Species)
Put the math symbols (greek letters, binary or relation operators) or equations within $ math symbol here $ signs to generate -
\(X_1\) with $ X_{1} $
$Y^{2}$ with $ X{2} $
\(X_{123}\) with $ X_{123} $
\(\pi\) with $ \pi $
\(\frac{N}{D}\) with $ \frac{N}{D} $
\(Prob \ (AB)=\frac{N}{D}\)
\(\bar x\) with $ \bar x $
\(\hat y\) with $ \hat y $
If the math Latex math symbols are not working/giving your errors even with HTML format, it could be due to you not being connected online. You could simply install Latex locally to avoid this issue.
Again, please read the R markdown cheat sheet for more features.
Use the Outline view, and Code Chunk view to navigate your document more effortlessly.
Do note that # have the same regular comment meaning in a code chunk, but a heading/subheading implication outside R code chunks in the .Rmd documents.
Not required, but may be worth a check for the future.