Hey, I am trying to graph a series of XY plots from a set of .csv files. Getting the csv files read in and the original plot set up is not a problem, but I cannot figure out a way to call get(iterator) within a separate dataset. A chunk of my code is below.
data <- read.csv(file= filename) data2 <- read.csv(file= filename2) names <- names(data) attach(data) for (item in names) { jpeg(filename=sprintf(directory_%s.jpg, item) plot(SiO2, get(item), pch="", ylab=sprintf("%s", item)) points(alith$SiO2, alith$get(item), pch=21, col="red") points(blith$SiO2, blith$get(item), pch=21, col="blue") points(clith$SiO2, clith$get(item), pch=21, col="green") points(dlith$SiO2, dlith$get(item), pch=21, col="orange") points(glith$SiO2, glith$get(item), pch=21, col="red4") points(hlith$SiO2, hlith$get(item), pch=21, col="purple") points(llith$SiO2, llith$get(item), pch=21) dev.off() } Ideally this would spit out hundreds of xy plots (and it does work if I plot them all in the same color by turning the pch="" off. However, when calling from a dataset with $, it will not let you use a function as the argument (the get(item) part gives an error). Is there any way around this? Thanks Taylor ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.