문제

for (i in 1:8){
  hist(x, main="Histrogram i")
}

Is it possible to evaluate the variable i, so that I get 8 histograms titled "Histogram 1", "Histogram 2", ... ?

도움이 되었습니까?

해결책

You will have to construct the character strings using paste.

par(mfrow = c(2, 2))
for (i in 1:4) {
  hist(rnorm(100), main = paste("Histogram", i))
}

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top