Message-ID: <x27k9lz0d4.fsf@biostat.ku.dk>
Date: 2003-04-23T15:42:31Z
From: Peter Dalgaard
Subject: How do I get 10^4 to become 10000?
In-Reply-To: <p05210600bacc4f6eab29@[128.115.153.6]>
Don MacQueen <macq at llnl.gov> writes:
> How about this?
>
> > a <- c('10^4','1.2^3','2.3')
>
> > as.numeric(gsub('\\^','E',a))
> [1] 1.0e+05 1.2e+03 2.3e+00
>
> This solution doesn't work for "10^(-5)" but does work for "10^-5".
>
Didn't work too well for 1.2^3 by some standards...
> a <- c('10^4','1.2^3','2.3')
> sapply(parse(text=a),eval)
[1] 10000.000 1.728 2.300
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907