-
Notifications
You must be signed in to change notification settings - Fork 56
/
SampleRDoc.Rmd
57 lines (45 loc) · 1.38 KB
/
SampleRDoc.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
55
56
57
---
title: "Sample R Document"
author: "jatawatsafe"
output:
html_document:
df_print: paged
---
## 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>.
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:
## Import Lib
```{r packages, message=FALSE, warning=FALSE}
library(dplyr)
library(rmarkdown)
```
## Create Varaible
```{r var}
sample3 <- c("Male","Female","Male","Female","Female")
gender <- factor(sample3)
class(gender)
summary(gender)
```
## Explore Data
```{r explore}
glimpse(starwars)
```
## Plots
You can also embed plots, for example:
```{r}
barplot(starwars$height)
```
## Transformation Data
```{R}
starwars %>% group_by(species) %>%
summarise(height=mean(height,na.rm = T),mass=mean(mass,na.rm = T)) %>%
mutate(BMI = mass / ((height/100)^2)) %>%
arrange(desc(BMI)) %>%
head(10)
```
## Notes
- Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the **R code**
but the result will shown
### Save
- Click button `Knit` to save in HTML
- If output is `github_document`, run function `render("fileName.Rmd")` in console to save