-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRMarkdown_Intro.Rmd
55 lines (39 loc) · 1.92 KB
/
RMarkdown_Intro.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "My First Markdown Document"
author: "DataTeka"
date: "`r Sys.Date()`"
output: html_document
#output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# R Markdown
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>.
Material from today's workshop can be found on our GitHub page.
When analysing data, a starting point is to examine the characteristics of each individual variable in the data set. The way to proceed depends upon the type of variable being examined. The variables can be one of two broad types:
Attribute variable: has its outcomes described in terms of its characteristics or attributes;
Measured variable: has the resulting outcome expressed in numerical terms.
## Including R Code
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:
```{r cars}
install.packages("dplyr", repos = "http://cran.us.r-project.org")
install.packages("ggplot2", repos = "http://cran.us.r-project.org")
install.packages("gapminder", repos = "http://cran.us.r-project.org")
summary(cars)
cars[1:10, ]
```
## Including Plots
You can also embed plots by setting `echo = FALSE` to the code chunk to prevent printing of the R code that generates the plot. For example:
```{r, echo=FALSE}
boxplot(mpg ~ cyl, data = mtcars, horizontal = T)
```
## Including Mathematical Equations
Let us fit the following model $lifeExp = b_0 + b_1pop + b_2gdpPercap$ which we write using the [LaTeX](https://en.wikibooks.org/wiki/LaTeX/Mathematics).
```{r}
library(gapminder)
m1 <- lm(gapminder$lifeExp ~ gapminder$pop + gapminder$gdpPercap)
summary(m1)
```
What do we think of this model?
#### **Let's discuss it next time we meet up.**