On Tuesday 31 January 2006 06:55, Gabor Grothendieck wrote:
On 1/30/06, Patricia J. Hawkins [EMAIL PROTECTED] wrote:
[...snip...]
#which generalizes to:
bb - matrix(1:50, ncol=10, nrow=5, byrow=TRUE)
bv - as.vector(bb)
ai - as.vector(aa) + rep((1:nrow(aa)-1)*10, each=3)
bv[ai] -
Dear R-helpers,
I'm trying to develop a function which specifies all possible expressions that
can be formed using a certain number of variables. For example, with three
variables A, B and C we can have
- presence/absence of A; B and C
- presence/absence of combinations of two of them
-
Adrian DUSA adi at roda.ro writes:
I'm trying to develop a function [...snip...]
Sorry for the traffic, I forgot to say that I'm using
library(combinat)
for the combn function...
Thank you,
Adrian
__
R-help@stat.math.ethz.ch mailing list
this looks similar:
do.call(expand.grid,split(t(replicate(3,c(0,1,NA))),1:3))
Adrian DUSA a écrit :
Dear R-helpers,
I'm trying to develop a function which specifies all possible expressions that
can be formed using a certain number of variables. For example, with three
variables A, B and C
Hello,
Not exactly the same. By the way, why do you use do.call()? Couldn't you
do simply:
expand.grid(split(t(replicate(3, c(0, 1, NA))), 1:3))
Best,
Philippe Grosjean
Jacques VESLOT wrote:
this looks similar:
do.call(expand.grid,split(t(replicate(3,c(0,1,NA))),1:3))
Adrian DUSA a
On Monday 30 January 2006 14:40, Philippe Grosjean wrote:
Hello,
Not exactly the same. By the way, why do you use do.call()? Couldn't you
do simply:
expand.grid(split(t(replicate(3, c(0, 1, NA))), 1:3))
Best,
Philippe Grosjean
Jacques VESLOT wrote:
this looks similar:
On Monday 30 January 2006 14:40, Philippe Grosjean wrote:
Hello,
Not exactly the same. By the way, why do you use do.call()? Couldn't you
do simply:
expand.grid(split(t(replicate(3, c(0, 1, NA))), 1:3))
Just for the sake of it, the above can be even more simple with:
expand.grid(lapply(1:3,
I tried to let this pass, but failed:
lapply(1:3, function(x) c(0, 1, NA))
might more clearly be written as
rep(list(c(0, 1, NA)), 3)
Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)
Adrian Dusa wrote:
On
On Monday 30 January 2006 21:44, Patrick Burns wrote:
I tried to let this pass, but failed:
lapply(1:3, function(x) c(0, 1, NA))
might more clearly be written as
rep(list(c(0, 1, NA)), 3)
Indeed! Excellent, thanks :)
Hmm, I was just thinking perhaps my first example was too cluttered to
AD == Adrian Dusa [EMAIL PROTECTED] writes:
AD set.seed(5)
AD aa - matrix(sample(10, 15, replace=T), ncol=5)
AD bb - matrix(NA, ncol=10, nrow=5)
AD for (i in 1:ncol(aa)) bb[i, aa[, i]] - c(0, 1, 0)
AD Is there any possibility to vectorize this for loop?
AD (sometimes I have hundreds of columns
On 1/30/06, Patricia J. Hawkins [EMAIL PROTECTED] wrote:
AD == Adrian Dusa [EMAIL PROTECTED] writes:
AD set.seed(5)
AD aa - matrix(sample(10, 15, replace=T), ncol=5)
AD bb - matrix(NA, ncol=10, nrow=5)
AD for (i in 1:ncol(aa)) bb[i, aa[, i]] - c(0, 1, 0)
AD Is there any possibility to
11 matches
Mail list logo