2017-03-26 47 views
0

我需要一種方法來改變main的迭代器「i」,例如main =「Grafico de credibilidad」+ i,然後當6情節出現他們的標題變化像「Grafico de credibilidad 1」,並且1增加。r plot main,在R plot的主要選項中的迭代器

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() 
} 

非常感謝。

回答

0

您可以使用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() 
} 
+0

謝謝你,它的工作這麼好。 –