because they use split() to avoid the repeated
> evaluations of
> bigVector[ anotherBigVector == scalar ]
> that your nested (not imbricated) loops do. If you really need to convert
> the matrix to a list of lists that will probably be a quick transformation.
>
> Bill Dunl
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Duncan Murdoch
> Sent: Wednesday, August 10, 2011 9:43 AM
> To: Frederic F
> Cc: r-help@r-project.org
> Subject: Re
Hi Frederic,
shouldn't there be an result for the 3rd row as well, eg ls1$b$Y?
Maybe this will do what you want?
dtf<-within(dtf,index<-factor(A:B))
tapply(dtf$C,dtf$index,list)
Hth.
Am 10.08.2011 16:30, schrieb Frederic F:
> Hello Duncan,
>
> Here is a small example to illustrate what I am
On 10/08/2011 10:30 AM, Frederic F wrote:
Hello Duncan,
Here is a small example to illustrate what I am trying to do.
# Example data.frame
df=data.frame(A=c("a","a","b","b"), B=c("X","X","Y","Z"), C=c(1,2,3,4))
# A B C
# 1 a X 1
# 2 a X 2
# 3 b Y 3
# 4 b Z 4
### First way of getting the list
Hello Denis,
> To borrow shamelessly from one of the prominent helpers on this list:
> "What is the problem you're trying to solve?" Â Â (attribution: Jim Holtman)
I'm trying to connect two sets of legacy R tools: the output of the
first one can be transformed in a data.frame without loss of
inf
Hello Duncan,
Here is a small example to illustrate what I am trying to do.
# Example data.frame
df=data.frame(A=c("a","a","b","b"), B=c("X","X","Y","Z"), C=c(1,2,3,4))
# A B C
# 1 a X 1
# 2 a X 2
# 3 b Y 3
# 4 b Z 4
### First way of getting the list structure (ls1) using imbricated lapply
To borrow shamelessly from one of the prominent helpers on this list:
"What is the problem you're trying to solve?"(attribution: Jim Holtman)
I have the sense you want to do something over many subsets of your
data frame. If so, breaking things up into lists of lists of lists is
not necessari
I would use the tapply function (which is designed for the case in which
data exists for most pairs of the levels of A and B) or the
reshape::sparseby function, or something else in the reshape package.
These won't give you exactly the structure you were asking for, but they
will separate the d
Hi
Something to get you started
? as.list
a data.frame can be regarded as a 2 dimensional array of list vectors
df = data.frame(a=1:2,b=2:1,c=4:5,d=9:10)
as.list(df[,1:3])
$a
[1] 1 2
$b
[1] 2 1
$c
[1] 4 5
see also
http://cran.ms.unimelb.edu.au/doc/contrib/Burns-unwilling_S.pdf
Regards
Dunca
9 matches
Mail list logo