forked from thunguyen177/Big-data-resources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rmarkdown.Rmd
104 lines (74 loc) · 2.84 KB
/
Rmarkdown.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
title: "Rmarkdown & some R things"
author: "Thu Thi Nguyen"
date: "April 14, 2018"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Header 1: Introduction & Resource:
**Resource on Rmarkdown**:
+ Tutorial:
- [markdowntutorial.com] (https://www.markdowntutorial.com/)
+ Rmarkdown cheatsheet:
- [Cheat sheet 1](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf)
- [Cheat sheet 2](https://www.rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf)
Click here to go to [Shiny apps tutorial](https://shiny.rstudio.com/tutorial/)
## Header 2: Some troubleshooting for R:
* _Detach the package_:
1. Some packages does not work very well with other packages.
2. Sometimes, functions in different packages can have the same name but different in usage and meanings.
So, in some cases, you might want to detach the former package if you want to use another package for analysis and no longer wish to use the previous one. This can help you avoid misleading results.
* Clear the environment/old data when re-analyze the data. Moreover, if you are about to work with a big data set, clearing the environment might help R run faster in its impending sessions.
**_It's time for some code!_ **
NOT **_ It's time for some code! _ **
- "Eval" stand for evaluate
- Choose "echo = TRUE" to show the code
```{r,eval=FALSE, echo=TRUE}
f = expression(x^2 + y + z + w)
x = 1; y = 2; z = 3; w = 4
eval(f)
```
By default, eval=TRUE
```{r,echo=TRUE }
f = expression(x^2 + y + z + w)
x = 1; y = 2; z = 3; w = 4
eval(f)
```
- "echo = FALSE" to hide the code (this is default)
```{r}
f = expression(x^2 + y + z + w)
x = 1; y = 2; z = 3; w = 4
eval(f)
```
- "warning = FALSE" prevents warnings that are generated by code from appearing in the finished.
```{r, echo=TRUE}
x = c(1:10,10,11)
ks.test(x,"pnorm",1,2)
```
```{r, echo=TRUE, warning = FALSE}
x = c(1:10,10,11)
ks.test(x,"pnorm",1,2)
```
Using inline code, we have $2 + 2 = `r 2+2`$
```{r, echo=TRUE}
library(dplyr)
iris %>%
group_by(Species) %>%
summarise_all(mean)
# g_iris = group_by(iris,Species)
# upgroup(g_iris)
starwars %>% summarise_at(c("height", "mass"), mean, na.rm = TRUE)
starwars %>% summarise_if(is.numeric, mean, na.rm = TRUE)
```
Table Header | Second Header
-------- | -------------
Table Cell | Cell 2
Cell 3 | Cell `r 2*2`
## Something more
- [R for android installation](https://www.r-bloggers.com/install-r-in-android-via-gnuroot-no-root-required/)
- [shiny apps gallery](https://shiny.rstudio.com/gallery/)
- [Advanced R by Hadley Wickham](http://adv-r.had.co.nz/)
NOT [Advanced R by Hadley Wickham] (http://adv-r.had.co.nz/)
- Find this presentation on my Github:https://github.com/thunguyen177