[R] indexing
jim holtman
jholtman at gmail.com
Thu Mar 27 03:02:33 CET 2008
Is this what you were asking for?
> x <- c('a b', 'c d', 'e f')
> y <- strsplit(x, ' ')
> y
[[1]]
[1] "a" "b"
[[2]]
[1] "c" "d"
[[3]]
[1] "e" "f"
> sapply(y, '[[', 1)
[1] "a" "c" "e"
>
>
On Wed, Mar 26, 2008 at 8:55 PM, <gbr0wn at comcast.net> wrote:
> Is there an on-line source that explains index vectors? I used 'strsplit' to generate a lengthy list of pairs of character vectors. I only want the first of each pair. Brackets, double brackets, and '$' operator don't work
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list