Message-ID: <004501c24e88$5716dc70$a81401a3@stats.ox.ac.uk>
Date: 2002-08-28T11:45:00Z
From: Adaikalavan Ramasamy
Subject: Coercing character string to function argument ?
> indices <- c(1:5, 20:25, 50, 99)
> is.numeric(indices)
[1] TRUE
----- Original Message -----
From: "Derek Eder" <Derek.Eder at neuro.gu.se>
To: "<" <r-help at stat.math.ethz.ch>
Sent: Wednesday, August 28, 2002 12:32 PM
Subject: [R] Coercing character string to function argument ?
> I need to turn the character string: "1:5, 20:25, 50" into indices for
subsetting a vector.
>
> For example:
>
> indices <- "1:5, 20:25, 50, 99"
> vector <- rnorm(100,0,1)
>
> # Please R, show me the way to achieve this: vector[indices]
>
>
> I thank you angels in advance for rushing in where this fool got bogged
down!
>
> - Derek
>
> Derek N. Eder
> G?teborgs Universitet
> Institutionen f?r klinisk neurovetenskap
> Klinisk Neurofysiologi
> Sahlgrenska universitetssjukhuset SS/SU
> Bl? straket 7, v?n 3
> SE 413 45 G?teborg
> Sverige
> Tlf. +46 (031) 34 2-6139 (office)
> Tlf. +46 (031) 34 2-1283 (laboratory)
> Tlf. +46 0709 / 7 2-1283 (mobil)
> Fax. +46 (031) 82 81 63
> derek.eder at neuro.gu.se
>
>
> Gothenburg University
> Institute of Clinical Neuroscience,
> Department of Clinical Neurophysiology
> Salhgrenska Hospital SU/SS
> SE 413 45 G?teborg
> Sweden
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
> 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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._