[R] Bind field of a list

2010-02-19 Thread statquant

Hello all
I am new in R and so easy stuff are difficult...
let say that I have a list 
test <- list(a=c("x","v"),b=c("n","m"))
how can I without a loop get test$a bind with test$b (obviously in real life
their would be many fields)

Cheers and thanks
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561676.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bind field of a list

2010-02-19 Thread statquant

Hello,
Thank you but I think not what I would like to get as an answer is the list
("x","v","n","m") + what you gave me could work for 2 fields but if I have
200...


What I want is a vectorize way to do 
bindlists <- function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}

Regards
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bind field of a list

2010-02-19 Thread statquant

Bravo baptiste it works
what does do.call do exactly ??
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561745.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Accessing values of a matrix

2010-02-19 Thread statquant

hello all,
thank you for taking the time

I have a matrix A that have column names (let say n columns), I want to
reduce the matrix to have just a few of those column (p colums, this is
trivial), but for the lines I want only the lines such that A(i,J) is part
of a list (J is fixed and known)

I am sure it is very easy but I don't find it (I tryed which but it doesn't
seem to work)
Surely I could do a loop but I want to learn how to do things without time
consuming loops.

Thanks
Colin
-- 
View this message in context: 
http://n4.nabble.com/Accessing-values-of-a-matrix-tp1561932p1561932.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Accessing values of a matrix

2010-02-22 Thread statquant

Hello Sarah, thanks for answering
For example if I have the following example 

 test <- as.data.frame(matrix(c(1,2,3,4, 11,12,13,14, "a","b","b","c"), nrow
= 3, ncol=3,dimnames = list(c("r1","r2","r3","r4"),NULL))

   V1 V2 V3
r1  1 11  a
r2  2 12  b
r3  3 13  b
r4  4 14  c

it is easy to select test <- test[,mylist] with for example mylist <-
c("V1","V3")

   V1 V3
r1  1  a
r2  2  b
r3  3  b
r4  4  c

But after how can I restrict test in selecting the rows where the result in
column V3 are in a list mylist2, with for example mylist2 <-c("b","c","d") ?
which would give as an example 

   V1 V3
r2  2  b
r3  3  b
r4  4  c

Regards 
Colin
-- 
View this message in context: 
http://n4.nabble.com/Accessing-values-of-a-matrix-tp1561932p1564533.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Accessing values of a matrix

2010-02-22 Thread statquant

OKKK

Thanks a lot for letting me know the subset function
Cheers
-- 
View this message in context: 
http://n4.nabble.com/Accessing-values-of-a-matrix-tp1561932p1564724.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.