[R] converting a string to an integer vector

arun smartpink111 at yahoo.com
Thu Oct 18 17:50:24 CEST 2012


Hi,
You can also try this:
a <- "1,2"

as.numeric(c(gsub("(.*)\\,(.*)","\\1",a), gsub("(.*)\\,(.*)","\\2",a)))
#[1] 1 2






----- Original Message -----
From: BenM <bmmoskow at amath.washington.edu>
To: r-help at r-project.org
Cc: 
Sent: Thursday, October 18, 2012 10:17 AM
Subject: Re: [R] converting a string to an integer vector

Thank you very much.  That appears to be what I wanted.



--
View this message in context: http://r.789695.n4.nabble.com/converting-a-string-to-an-integer-vector-tp4646610p4646624.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.





More information about the R-help mailing list