[R] How to slice the array?

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Mon Nov 1 23:05:08 CET 2021


Hi Alice,
I can see from your two questions that your English is a bit shaky.
This is not a criticism, I couldn't speak Chinese to save my life. I
looked around for a Chinese R help mailing list and couldn't find one.
Perhaps someone else knows of one. Not only would it make your life
easier at the moment, but it may help you learning R jargon in
English.

Jim

On Tue, Nov 2, 2021 at 6:49 AM Alice <alice using coakmail.com> wrote:
>
> How to slice the array with the condition?
> For example, in perl I can get the elements greater than 2.
>
> $ perl -le '@x=(1,2,3,4,5);@y=grep {$_>2} @x;print "@y"'
>
> 3 4 5
>
>
> in R I know which(x>2), but it will return the indexes instead of an array.
>
>
> Thanks again.
>
>
> Alice
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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