Jonas Stein <news <at> jonasstein.de> writes: > > Hi, > > i would like to plot a few hundred .csv files. > Each file contains one curve with x,y values to plot. > > I have been searching for "gnu r read many files qplot" > and similar words. I found for loops that use assign to generate > one variable containing a dataframe. > > When i uesed the classic "plot' command i could add > the curves with something like > > for... { > data<-read.csv.... > points(data$x, data$y, col=myrainbow, type="l") > } > > How would you solve it in ggplot? > > Kind regards, >
I would use something along the lines of L <- lapply(list.files(pattern),read.csv) to read the files into a list. Something like L2 <- mapply(function(i,x) { data.frame(file=i,x) },seq_along(L),L) to add an index column to each data frame L3 <- do.call(rbind,L2) to combine them all into a single data frame and ggplot(L3,aes(x=x,y=y,group=file))+geom_line() ______________________________________________ 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.