Use # for headings:
# Heading 1## Heading 2### Heading 3Inline maths: \(\alpha + \beta = \gamma\).
Display maths:
\[ E = mc^2 \]
Here’s a simple code chunk:
x <- rnorm(100)
y <- x + rnorm(100, sd = 0.5)
summary(lm(y ~ x))
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.09041 -0.29377 0.02269 0.39657 1.03896
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.01299 0.04612 0.282 0.779
## x 0.91631 0.04405 20.800 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4594 on 98 degrees of freedom
## Multiple R-squared: 0.8153, Adjusted R-squared: 0.8134
## F-statistic: 432.6 on 1 and 98 DF, p-value: < 2.2e-16
Here’s a code chunk that creates a scatterplot using the ggplot package
library(ggplot2)
df <- data.frame(x = x, y = y)
ggplot(df, aes(x = x, y = y)) +
geom_point(colour = 'steelblue') +
geom_smooth(method = 'lm', se = FALSE) +
ggtitle("Scatterplot of y versus x") +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'