简体   繁体   English

使用lapply和plot绘制多个图

[英]use lapply and plot to draw multiple plots

try to run the following code, but always got error message: 尝试运行以下代码,但始终收到错误消息:

Error in text.default(x, y, txt, cex = cex, font = font) : invalid mathematical annotation text.default(x,y,txt,cex = cex,font = font)中的错误:无效的数学注释

par(mfrow=c(2,3))
x <- c(1:4,6:9)
myPlot<-function(x){
    plot(pros.dat, pros.dat$svi ~ pros.dat[,x])
}
lapply(c(1:4,6:9), FUN=myPlot)

Could anybody tell me what's wrong? 有人可以告诉我怎么了吗? Thanks 谢谢

R's plot function's definition is: R的绘图函数的定义为:

plot(x, y, ...)

So you should define your function as: 因此,您应该将函数定义为:

myPlot<-function(x){
    plot(pros.dat$svi, pros.dat[,x])
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM