我需要一种方法来更改主图,其中的迭代器"i",例如main = "Grafico de credibilidad" + i,然后当 6 个图出现时,它们的标题会像"Grafico de credibilidad 1"一样变化,并且 1 会增加。
momentos1 <- read.table("momentos1.txt")
par(mfrow = c(2,3),bg = "white")
x<-seq(0,1,0.01)
for(i in 1:6){
plot(x,dbeta(x,momentos1$alpha.1.30.[i],momentos1$beta.1.30.[i]),
main = "Grafico Credibilidad",axes = F,col="blue",
ylab = "",
xlab = "",
ylim = c(0,5),type = "l"
)
axis(1,at = seq(0,1,0.1),las=1)
box()
grid()
}
多谢。
您可以使用
paste()
momentos1 <- read.table("momentos1.txt")
par(mfrow = c(2,3),bg = "white")
x<-seq(0,1,0.01)
for(i in 1:6){
plot(x,dbeta(x,momentos1$alpha.1.30.[i],momentos1$beta.1.30.[i]),
main = paste("Grafico Credibilidad ",i),axes = F,col="blue",
ylab = "",
xlab = "",
ylim = c(0,5),type = "l"
)
axis(1,at = seq(0,1,0.1),las=1)
box()
grid()
}