问答详情
源自:3-6 Lattice绘图系统之实践

按照老师的程序输入为什么遇到了layout错误?

set.seed(1)

x <- rnorm(100) 

f <- rep(0:1, each = 50) 

y <- x + f - f*x + rnorm(100, sd = 0.5) 

f <- factor(f, labels = c("Group1", "Group2")) 

xyplot(y~x | f, layout(2,1)) 

然后为啥出现错误? 

Error in layout(2, 1) : layout matrix must contain at least one reference to each of the values {1 ... 2}

提问者:qq_肖西耶_0 2017-09-16 09:59

个回答

  • qq_肖西耶_0
    2017-09-16 10:05:23

    已经知道原因,我没有抄对。layout(2,1)应该是layout=c(2,1)