-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy path03-basicFunction.Rmd
More file actions
85 lines (69 loc) · 1.98 KB
/
03-basicFunction.Rmd
File metadata and controls
85 lines (69 loc) · 1.98 KB
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
# 基本绘图函数 {#baseFunction}
## 散点图
散点图需要的输入是data.frame,需要指定`xvar`和`yvar`, `series`为可选的颜色分度参数,
```{r echo = FALSE}
library(recharts)
```
```{r}
ePoints(iris[, 3:5], theme = 2)
iris$Species <- as.character(iris$Species)
iris[1:20, "Species"] = "redFlower"
ePoints(iris[,3:5], xvar = ~Petal.Length, yvar = ~Petal.Width, series = ~Species, theme = 1)
ePoints(iris[,3:5], xvar = ~Petal.Length, yvar = ~Petal.Width, series = ~Species, theme = 6)
```
## 线图
```{r results='hold'}
head(WorldPhones)
eLine(WorldPhones, theme=1)
```
```{r warning=FALSE}
#mode 2 input.
df2 <- data.frame(
saleNum=c(10,20,30,40,50,60,70,15,25,35,45,55,65,75,25,35,45,55,65,75,85),
seller=c(rep("Yellow",7), rep("Red",7), rep("White",7)),
weekDay = c(rep(c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),3)),
stringsAsFactors =FALSE
)
eLine(df2, xvar=~weekDay, yvar= ~saleNum, series=~seller)
dat <- cut(rnorm(1000), -4:4)
eLine(dat)
```
## 条形图
```{r}
require(plyr)
dat = ddply(iris, .(Species), colwise(mean))
rownames(dat) = dat[,1]
dat = dat[, -1]
dat
eBar(dat)
eBar(dat, horiz = TRUE)
#mode 2 input.
df2 <- data.frame(
saleNum=c(10,20,30,40,50,60,70,15,25,35,45,55,65,75,25,35,45,55,65,75,85),
seller=c(rep("Yellow",7), rep("Red",7), rep("White",7)),
weekDay = c(rep(c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),3)),
stringsAsFactors =FALSE
)
dat <- df2
xvar=~weekDay; yvar= ~saleNum; series=~seller
eBar(df2, xvar = ~seller, ~saleNum, ~weekDay )
eBar(df2, xvar = ~seller, ~saleNum, ~weekDay, stack=T)
eBar(df2, xvar = ~seller, ~saleNum, ~weekDay, stackGroup = list(c('Sat','Sun')))
dat <- df2[1:7,]
eBar(dat, ~weekDay, ~saleNum)
dat <- cut(rnorm(1000), -4:4)
eBar(dat)
```
## 饼图
```{r}
x = runif(6)
names(x) = LETTERS[1:6]
ePie(x) + eTitle("test")
testData <- head(mapTestData_chs, 5)
ePie(testData, ~stdName, ~val1)
```
```{r}
x = runif(6)
names(x) = LETTERS[1:6]
ePie(x,reset_radius = c(80,120),showL = T,labelformatter = "{b}:{c}")
```