[R] plotting single variables common to multiple data frames

John Kane jrkrideau at yahoo.ca
Tue May 24 15:55:06 CEST 2011


None of the files came through.  The R-help list routinely srips off all attachments to cut down on the change of viri .  

You could provide the data in the email by using dput.  Type ?dput in the R console to get the help page.

It is not clear from what you write whether you want a line with one set of data consisting of all the data from the seven files or if you want 7 lines (dots whatever) one for each day.

A brute force way for the first approach is to combine all the data.frames using rbind, and plot from there.  

Example
=====================================================
xx <- data.frame(aa=1:10, bb = letters[1:10])
yy  <- data.frame(aa=11:20,  bb = letters[11:20])
zz <- data.frame(aa=21:30, bb= sample(letters[1: 26], 10))

df1 <- rbind(xx,yy,zz)
plot(df1$aa)


======================================================

If you want 7 sets someone else probably has a simple solution. Without your sample data it's bit bit hard to guess.







--- On Tue, 5/24/11, Mathew Brown <mathew.brown at forst.uni-goettingen.de> wrote:

> From: Mathew Brown <mathew.brown at forst.uni-goettingen.de>
> Subject: [R] plotting single variables common to multiple data frames
> To: r-help at r-project.org
> Received: Tuesday, May 24, 2011, 8:55 AM
> 
> 
> 
> Hello all,
> 
> I have files (see attached) which are created daily. I want
> to load
> about a weeks worth of them (7 daily files) and plot a
> weeks worth of
> one variable together. So one variable name is delta_D_H. I
> would like
> to plot this variable from all 7 days on one plot. I'm
> having trouble
> figure out how to do this.
> 
> I've loaded them all up using this
> 
> time=Sys.time()
> t1<- as.numeric(format.Date(time, "%Y%m%d"))
> #date range of data to load
> paluiso= c(); yy = c();
> t1=t1-1
> t0<-t1-7
> x = t0:t1
> for (i in seq( length(x) ) ) {
>      
> y=load(paste(datalocation,x[i],".RData", sep=""))
>       e3<- new.env()
>    yy[[i]]<- get('isot', e3)
> }
> 
> but I don't know how to grab single variables from these
> data frames and
> plot them.
> 
> Any help is appreciated!
> 
> M





More information about the R-help mailing list