Skip to content

From data frame to list object

1 message · Christofer Bogaso

#
Sorry if I did not clarify that. Here I have a data frame with many columns,
which was taken from some outside DB. Now I want to split that data frame
and create a "list" object (to make my further calculation easier), on basis
of a typical column of that DB. I cannot post my original DB here (due to
some security reason and ofcourse it's huge size), therefore I posted an
artificial DB.

Here my artificial DB with 3 columns:

dfrm <- data.frame(x=rnorm(18), y=rep(c("a", "b", "c"), each=6),
z=rep(c("x", "y", "z"), each=2))

I would like to create a list object where each element now is a matrix or
data frame, based on that "y" column. 1st element of that list will be a
data frame with observations of "x" and "z" columns, that address the
attribute "y = a". Similarly other two.

Hope I could be able to make my intentions clearer.

Any idea how I can achieve that?

Thanks,



-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: 01 February 2011 00:13
To: Bogaso Christofer
Cc: r-help at r-project.org
Subject: Re: [R] From data frame to list object
On Jan 31, 2011, at 1:56 PM, Bogaso Christofer wrote:

            
You will need to specify what you goals are. What to you want to  
happen to those two columns referred to by dfrm[, c(1,3)]? It's  
possible that split() may be the answer, but clarify the goals first.  
You should provide an example that represents the complexity of the  
task.
David Winsemius, MD
West Hartford, CT