Here is a brief introduction into using R Markdown. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. R Markdown provides the flexibility of Markdown with the implementation of R input and output. For more details on using R Markdown see https://rmarkdown.rstudio.com.
Be careful with your spacing in Markdown documents. While whitespace largely is ignored, it does at times give Markdown signals as to how to proceed. As a habit, try to keep everything left aligned whenever possible, especially as you type a new paragraph. In other words, there is no need to indent basic text in the Rmd document (in fact, it might cause your text to do funny things if you do).
It's easy to create a list. It can be unordered like
or it can be ordered like
Notice that I intentionally mislabeled Item 2 as number 4. Markdown automatically figures this out! You can put any numbers in the list and it will create the list. Check it out below.
To create a sublist, just indent the values a bit (at least four spaces or a tab). (Here's one case where indentation is key!)
Make sure to add white space between lines if you'd like to start a new paragraph. Look at what happens below in the outputted document if you don't: Here is the first sentence. Here is another sentence. Here is the last sentence to end the paragraph. This should be a new paragraph.
Now for the correct way:
Here is the first sentence. Here is another sentence. Here is the last sentence to end the paragraph.
This should be a new paragraph.
When you click the Knit button above 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 (mtcars is a
built-in R dataset):
summary(mtcars)
If you'd like to put the results of your analysis directly into your discussion, add inline code like this:
The
cosof $2 \pi$ isr cos(2*pi).
Another example would be the direct calculation of the standard deviation:
The standard deviation of
speedincarsisr sd(cars$speed).
One last neat feature is the use of the ifelse conditional statement which can
be used to output text depending on the result of an R calculation:
r ifelse(sd(cars$speed) < 6, "The standard deviation is less than 6.", "The standard deviation is equal to or greater than 6.")
Note the use of > here, which signifies a quotation environment that will be
indented.
As you see with $2 \pi$ above, mathematics can be added by surrounding the
mathematical text with dollar signs. More examples of this are in
[Mathematical equations].
Varsity blues already solves all the packages in order to insert plots right away from your code.
#| fig-width: 5 #| fig-height: 3 #| fig-cap: "An elementary plot" library(ggplot2) ggplot(mtcars) + geom_point(aes(x = cyl, y = wt, color = am))
As for the case of plots, this package already solves all the dependencies in order to use different types of tables in \LaTeX.
kable(xtabs(~ am, mtcars))
#| results: 'asis' library(stargazer) model1 <- lm(mpg ~ cyl, mtcars) model2 <- lm(mpg ~ cyl + am, mtcars) model3 <- lm(mpg ~ cyl + am + wt, mtcars) stargazer(model1, model2, model3, header = F, title = "Regression table")
\newpage
Consider a function $f: U \to \mathbb{R}$, defined on an open set $U\subset\mathbb{R}$, is said to be differentiable at $a\in U$ if the derivative $f'(a) = \lim_{h \to 0}\frac{f(a+h)-f(a)}{h}$ exists. In general, $f$ is of class $\mathcal{C}^k$ if its first $k$ derivatives $f^{\prime}(x), f^{\prime\prime}(x), \ldots, f^{(k)}(x)$ exist and are continuous.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.