[R] array slice notation?

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Wed Aug 5 09:13:19 CEST 2009


Hi,

1) I think vector subscripting is faster than the solution below.

2) I don't understand the question, but it may be an idea to look at ?tableSlice and ?tableMargin in the gRbase package.

Regards
Søren

________________________________________
Fra: r-help-bounces at r-project.org [r-help-bounces at r-project.org] På vegne af Steve Jaffe [sjaffe at riskspan.com]
Sendt: 5. august 2009 04:45
Til: r-help at r-project.org
Emne: Re: [R] array slice notation?

Very nice. Two questions:
1> Do you have any idea of the timing difference, if any, between this and
the vector-subscripting method?
2> How do  you generalize this to select multiple rows eg with indexes given
by a vector 'v'?


Søren Højsgaard wrote:
>
> You can do
>> A <- HairEyeColor
>> do.call("[", c(list(A),list(1,T,T)))
>        Sex
> Eye     Male Female
>   Brown   32     36
>   Blue    11      9
>   Hazel   10      5
>   Green    3      2
>
> Regards
> Søren
>

--
View this message in context: http://www.nabble.com/array-slice-notation--tp24814643p24819883.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.



More information about the R-help mailing list