[R] How do I get 10^4 to become 10000?

Don MacQueen macq at llnl.gov
Wed Apr 23 16:14:02 CEST 2003


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".

-Don

At 1:51 PM +1200 4/22/03, Patrick Connolly wrote:
>Of course, that's as trivial as it gets on the command line, but I
>can't work out how to get a column of numbers that are entered as
>"10^5" from its 'character' format into a numeric one?
>
>I feel a bit embarrassed asking such a simple question.  Too much
>Easter....
>
>Thanks
>
>
>
>--
>Patrick Connolly
>HortResearch
>Mt Albert
>Auckland
>New Zealand
>Ph: +64-9 815 4200 x 7188
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
>I have the world`s largest collection of seashells. I keep it on all
>the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
>~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA



More information about the R-help mailing list