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]]
I find R books to be helpful for beginners. There is a fairly
comprehensive list on the R web site, www.r-project.org.
Is this what you had in mind though? Without example code, it's hard
for me to tell exactly your situation.
test <- list(first = c("string1a", "string2a"), second =
c("string1b",
"string2b"))
sapply(test, "[[", 1)
Best,
Erik Iverson
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.
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?