r - Plot data from several large data files in ggplot -


i have several data files (numeric) around 150000 rows , 25 columns. before using gnuplot (where script lines proportional plot objects) to plot data have additional analysis moved r , ggplot2.

how organize data, thought? 1 big data.frame additional column mark file data coming option? or there way around that?

edit: bit more precise, i'll give example in form have data now:

filelst=c("filea.dat", "fileb.dat", "filec.dat") dat=c() for(i in 1:length(filelst)) {     dat[[i]]=read.table(file[i]) } 

assuming have filenames ending ".dat", here's mockup example of strategies proposed chase,

require(plyr)  # list files lf = list.files(pattern = "\.dat") str(lf)  # 1. read files data.frame d = ldply(lf, read.table, header = true, skip = 1) # or whatever options read str(d) # should contain data, , and id column called l1  # use data, e.g. plot pdf("all.pdf") d_ply(d, "l1", plot, t="l") dev.off() # or using ggplot2 ggplot(d, aes(x, y, colour=l1)) + geom_line()  # 2. read files list  ld = lapply(lf, read.table, header = true, skip = 1) # or whatever options read names(ld) = gsub("\.dat", "", lf) # strip file extension str(ld)   # use data, e.g. plot pdf("all2.pdf") lapply(names(l), function(ii) plot(l[[ii]], main=ii), t="l") dev.off()  # 3. not fun 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -