my loop only works for the last file R -
only last file in list of text files produces pdf. not sure why?
files <- (sys.glob("/users/local/documents/*segmentcn.txt")) (i in length(files)) { y <- read.table(files[i], header=true) cn1m0 <- subset(y, subset=(mcn == 0 & cn == 1), select = c("log2", "imba")) pdf(file = paste(files[i], ".pdf", sep="")) plot(cn1m0$log2, cn1m0$imba, col=128, xlim=c(-1, 1), ylim=c(0,1)) points(mean(cn1m0$log2), mean(cn1m0$imba), pch = 3, col="red") dev.off() }
the problem length(files) outputs length of list, you're taking last file.
try
for (i in 1:length(files)) or more safe:
for (i in seq(along = files))
Comments
Post a Comment