Re: [R] indexing a particular element in a list of vectors

2003-10-17 Thread Peter Dalgaard
Richard A. O'Keefe [EMAIL PROTECTED] writes: Scott Norton [EMAIL PROTECTED] wrote: I have a list of character vectors. I'm trying to see if there is a way (in a single line, without a loop) to pull out the first element of all the vectors contained in the list. You

RE: [R] indexing a particular element in a list of vectors

2003-10-17 Thread Simon Fear
Or do.call(cbind,x)[1,] which of course makes a whole new copy of x and gives you a nasty warning as well, but does not use a conceptual `for` loop. Which I think was the original question, to which AFAIK the answer is no, there is no easy subscripting construct such as x[[1:3]][1] that will do

Re: [R] indexing a particular element in a list of vectors

2003-10-16 Thread Richard A. O'Keefe
Scott Norton [EMAIL PROTECTED] wrote: I have a list of character vectors. I'm trying to see if there is a way (in a single line, without a loop) to pull out the first element of all the vectors contained in the list. You have a list. You want to do something to

RE: [R] indexing a particular element in a list of vectors

2003-10-15 Thread Simon Blomberg
How about: lst - list(c(a, b, c), c(d, e, f)) sapply(lst, function (x) x[1]) [1] a d Cheers, Simon. Simon Blomberg, PhD Depression Anxiety Consumer Research Unit Centre for Mental Health Research Australian National University http://www.anu.edu.au/cmhr/ [EMAIL PROTECTED] +61 (2) 6125 3379