[R] Selecting numbers not divisible by 3
Berend Hasselman
bhh at xs4all.nl
Thu Mar 27 12:23:46 CET 2014
On 27-03-2014, at 10:23, Prabhakar Ghorpade <dr.prabhakar08 at gmail.com> wrote:
> Hi,
> here's my code
>
> X <- 1:100
>
> I want to select number divisible by 3 out of them how can I select it?
>
> ( I tried following
> X <- 1:100
> DIV <- Y - > X/3
>
> But I am getting whole number and number with fractions. WHole intgers are
> my number of interest from original X. How can I traceback to number
> divisbile by 3. ?)
>
Please don’t send messages twice.
X <- 1L:100L
X[which(X%%3L==0L)]
and this gives the same results
X <- 1:100
X[which(X%%3==0)]
and beware of R FAQ 7.31 for more complicated situations.
Berend
And please don’t post in html as you are requested to do.
More information about the R-help
mailing list