Reputation: 5059
I have following (exponential) values and want to calculate their median using R:
1.0584e+00
1.1618e+01
4.9097e+00
1.3595e+01
4.2209e+01
4.6901e-01
2.4911e+00
1.2441e+01
6.8128e+00
1.3581e+01
1.4373e+01
1.2828e+00
7.7811e+00
Here is what I am doing:
data <- read.table("path")
median(data[ ,1])
Due to values being in exponential, I am not getting the correct median. Alternatively, you may also suggest how can I change these values into normal floating point values.
Upvotes: 2
Views: 2554
Reputation: 263332
What are you getting for the median. Seems to work for me. Maybe you have these as "factor"s and you need to convert with as.numeric(as.character())
> median(vec)
[1] 7.7811
> vec
[1] 1.05840 11.61800 4.90970 13.59500 42.20900 0.46901 2.49110 12.44100 6.81280 13.58100
[11] 14.37300 1.28280 7.78110
Upvotes: 4