R导入csv文件后利用vioplot函数绘制小提琴图
> exe3<-read.csv("C:/Users/A/Desktop/exercise3_3.csv")
> ##运行包
> install.packages("vioplot")
> library(vioplot)
> ##设置格式
> par(mai=c(0.6,0.6,0.3,0.3),cex=0.7)
> palette<-RColorBrewer::brewer.pal(3,"Set2")
> ##绘制小提琴图
> vioplot(exe3[1:2],col=palette,names=names,main="小提琴图",xlab="性别",ylab="身高")
library(vioplot)
##设置格式
par(mai=c(0.6,0.6,0.3,0.3),cex=0.7)
palette<-RColorBrewer::brewer.pal(3,"Set2")
##绘制小提琴图
vioplot(exe3[1:2],col=palette,names=names,main="小提琴图",xlab="性别",ylab="身高")
Error in axis(side = side, at = at, labels = labels, ...) :
cannot coerce type 'builtin' to vector of type 'character'
##exe3的数据为
exe3[1:2]
男生 女生
1 182.1 175.4
2 183.3 162.7
3 176.6 174.6
4 177.3 164.8
5 174.3 157.0
6 178.9 157.3
7 177.5 164.3
8 179.5 167.6
9 168.3 167.8
10 173.3 168.7
11 170.3 170.7
12 177.9 168.2
13 174.4 171.7
14 196.0 166.3
15 178.4 172.3
16 188.5 167.3
17 174.2 179.2
18 191.4 174.9
19 174.4 173.8
20 176.8 167.4
21 177.2 163.7
22 167.8 165.2
23 183.4 158.9
24 174.7 169.9
25 174.7 168.5
26 171.2 164.0
27 175.1 172.5
28 181.1 162.1
29 182.3 169.8
30 174.4 168.0
31 188.6 165.6
32 181.0 163.2
33 166.7 164.5
34 176.6 166.5
35 184.2 179.1
36 176.1 172.7
37 175.9 163.5
38 186.6 167.8
39 188.5 175.3
40 166.5 174.6
41 174.9 168.5
42 177.5 167.9
43 180.2 167.2
44 188.2 168.3
45 178.3 165.2
46 181.9 164.0
47 189.1 166.2
48 178.0 168.9
49 167.8 162.0
50 186.1 167.2
不知道为什么会报错Error in axis(side = side, at = at, labels = labels, ...) :
cannot coerce type 'builtin' to vector of type 'character'