-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRweek09.R
70 lines (51 loc) · 1.63 KB
/
Rweek09.R
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
# R programming Week 9
# Sungpil Han
Week09 <- c("tidyverse", "shiny", "dplyr", "ggplot2", "rmarkdown", "knitr", "flexdashboard", "ggsci")
#install.packages(Week09)
LibraryWeek09 <- lapply(Week09, library, character.only = TRUE)
#get help with a function
?c
#assign data to a variable
x <- c(77, 66, 88)
mean(x)
max(x)
#charts
plot(x)
barplot(x)
pie(x)
#' Plot navigation
#' export to the clipboard
#' Publish to http://rpubs.com/
# Demo: RStudio
#' - History
#' - Run from the beginneing
#' - Run to the end
#' - Plot
#'
# Create Shiny Web App
## Examples: shiny
shiny::runApp("Shiny")
shiny::runApp("app0")
shiny::runApp("app1")
shiny::runApp("app2") # install.packages("deSolve")
shiny::runApp("pk_pd") # PMx_2016
## Examples: ggplot2
library(ggplot2)
qplot(displ, hwy, data = mpg)
qplot(displ, hwy, data = mpg, color = drv)
qplot(displ, hwy, data = mpg, geom = c("point", "smooth"))
qplot(hwy, data = mpg, fill = drv)
qplot(displ, hwy, data = mpg, facets = . ~ drv)
qplot(hwy, data = mpg, facets = drv ~ ., binwidth = 2)
maacs <- read.csv("maacs.csv", as.is = TRUE)
str(maacs)
# examples of qplot
qplot(log(eno), data = maacs)
qplot(log(eno), data = maacs, fill = mopos)
qplot(log(eno), data = maacs, geom = "density")
qplot(log(eno), data = maacs, geom = "density", color = mopos)
qplot(log(pm25), log(eno), data = maacs)
qplot(log(pm25), log(eno), data = maacs, shape = mopos)
qplot(log(pm25), log(eno), data = maacs, color = mopos)
qplot(log(pm25), log(eno), data = maacs, color = mopos, geom = c("point", "smooth"), method = "lm")
qplot(log(pm25), log(eno), data = maacs, geom = c("point", "smooth"), method = "lm", facets = . ~ mopos)