Hello all,
I'm new to R and I cannot find a simple answer to a simple question.
If I have a character vector like v <- c('1/50,'1/2','1/8'...) how can
I convert it to a numeric vector like vn <- c(0.02,0.5,0.125...). I
tried as.numeric in various ways and failed miserably. Currently I use
a function like: for (e in v) { if (e=='1/50') vn<-c(vn,0.02) ...} but
that feels bad because it needs to be (humanly) modified everytime a
new fraction appears in v.
Thanks in advance,
--
Mihai.
______________________________________________
[email protected] 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.