[R] A sample question

Timothy H. Keitt tklistaddr at keittlab.bio.sunysb.edu
Tue Apr 30 23:49:38 CEST 2002


Try

x <- 1:10
x[-c(2,5)] <- 0


T.

On Tue, 2002-04-30 at 15:32, Ambrosini Alessandro wrote:
> Hello.
> Given a vector 1 3 4 2 8 9 5
> I want to obtain a vector with all 0 except in the second position and in
> the fifth, where the numbers are the same of the first vector.
> The new vector must be
>  0 3 0 0 8 0 0
> 
> Thank you very much.
> Excuseme but my mind is out of order.
> Alessandro
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list