[R] How to slice the array?

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Mon Nov 1 20:55:05 CET 2021

Have you spent time with any R tutorials? Your queries are really
elementary, and this list really cannot serve as a tutorial service. See
the Posting Guide linked below for what help you can expect here ... and
how to post queries that will get that help.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Nov 1, 2021 at 12:49 PM 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list