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.

1 Title: Major Heading here

This contains the link to R Markdown Cheatsheet. Please read it - it has everything you need to know about R Markdown for our course.

1.1 R Markdown: Sub Heading - Indent 2

This is my first attempt - normal text.

This is my second attempt - bold.

This is my third attempt - italicize.

1.1.1 Eval Function: Sub-sub Heading - Indent 3

  1. eval function evaluates code and includes its results in block.
  • Default is True, thus can be omitted.
  • Make False if code giving errors. R will skip evaluting the code chunk.
# 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.

1.1.2 Echo Function: Sub-sub Heading - Indent 3

  1. echo function controls display of code command. Use it if you do not want even the commands to be printed.
  • Default is TRUE.
  • Make False if you do not want R to not show print results - sometimes a single line command can generate too much output / many lines, makinf the output file too long / multiple pages.
?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.

1.1.3 Graphs: Sub-sub Heading - Indent 3

Can print graphs in your file too.

plot(iris[1:4], col=iris$Species)

1.2 Latex: Sub Heading - Indent 2

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.

1.3 Conclusion

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.