[R] Subsetting R 3.1.2

Lee, Chel Hee chl948 at mail.usask.ca
Fri Dec 5 19:44:19 CET 2014


Your question is not clear to me.

 > x$alpha[1:2]
[1] "a" "b"
 > x$alpha[2]
[1] "b"
 >

Is this what you are looking for?  I hope this helps.

Chel Hee Lee

On 12/5/2014 11:12 AM, Dinesh Chowdhary wrote:
>> x <- list(seq = 3:7, alpha = c("a", "b", "c"))
>> x$alpha
> [1] "a" "b" "c"
>
>> x["alpha"]
> $alpha
> [1] "a" "b" "c"
>
>> x[c(1,2)]
> $seq
> [1] 3 4 5 6 7
>
> $alpha
> [1] "a" "b" "c"
>
> *> x[c(1, alpha[2])]*
> *$<NA>*
> *NULL*
>
> *$<NA>*
> *NULL*
>
> How to access a character subset withing a list?
>
> Thank you for your effort...
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



More information about the R-help mailing list