On 27-03-2014, at 10:23, Prabhakar Ghorpade <dr.prabhaka...@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.
______________________________________________
R-help@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.

Reply via email to