2017-10-24 21 views
1

Graphics 그래픽을 사용하여 그래픽을 만들었습니다. lattice 패키지를 사용하여 변경하십시오.격자 패키지를 사용하여 그래픽 변경

par(mai = c(1, 1, 1, 1), omi = c(0, 0, 0, 0)) 
set.seed(591) 
xx1 <- rnorm(20, mean = 3, sd = 3.6) 
xx2 <- rpois(40, lambda = 3.5) 
xx3 <- rchisq(31, df = 5, ncp = 0) 
box1 <- boxplot(xx1, xx2, xx3, names = c("Group-1", "Group-2", 
"Group-3"), cex = 0.7) 

나는 시도했지만 작동하지 않습니다.

library(lattice) 
set.seed(591) 
type <- sample(c("Group-1", "Group-2", "Group-3"), n, replace = TRUE) 
xx1 <- rnorm(20, mean = 3, sd = 3.6) 
xx2 <- rpois(40, lambda = 3.5) 
xx3 <- rchisq(31, df = 5, ncp = 0) 
df <- data.frame(xx1, xx2, xx3) 
bwplot(xx1,xx2,xx3,data=df) 

enter image description here

은 사전에 감사합니다.

답변

2
set.seed(591) 
xx1 <- rnorm(20, mean = 3, sd = 3.6) 
xx2 <- rpois(40, lambda = 3.5) 
xx3 <- rchisq(31, df = 5, ncp = 0) 
df <- data.frame(xx = c(xx1,xx2,xx3), 
       type=c(rep(1,length(xx1)),rep(2,length(xx2)),rep(3,length(xx3)))) 
df$type <- factor(df$type, labels=c("Group-1", "Group-2", "Group-3")) 

library(lattice) 
bwplot(xx~type, data=df) 

enter image description here