nested for loop in R, using variable in title , -
can tell me what's wrong following syntax in r, , how can use variable "i" , "n" in text, title of plot?
j <- c(5,10,15,20) (n in j){ (i in 1:n) { cl[i] <- subset(data, data$cluster[n] == [i]) ... plot( ...., main="cl[i] , cluster[n]") }} error: unexpected '[' in: "for (i in 1:n) { cl[i] <- subset(data, data$cluster[n] == ["
use paste or paste0 command:
plot( ...., main=paste0("cl[", i, "] , cluster[", n, "]"))
Comments
Post a Comment