formatting - Convert "(3e+04,3.5e+04]" type to number in r -
i have data set of car speed on road, , distance of car start point of measuring.
i wanted check mean , se in each 5 km down road, sorted data 'distancefromstart' , made table using function build:
speedbykm <- function(testfile){ setdt(a1a2011)[, list(speed=mean(speed)), by=list(cut(distancefromstart,breaks= seq(0, max(distancefromstart)+5000, = 5000),include.lowest=true))]->res setdt(a1a2011)[, list(speed=se(speed)), by=list(cut(distancefromstart,breaks= seq(0, max(distancefromstart)+5000, = 5000),include.lowest=true))]->res1 res$se = res1$speed return(res) }
the table got is:
cut speed se 1: (3e+04,3.5e+04] 88.16993 0.04784163 2: (5e+03,1e+04] 94.33507 0.02121293 3: (2e+04,2.5e+04] 99.26032 0.03680951 4: (2.5e+04,3e+04] 90.31163 0.03991980 5: [0,5e+03] 94.69139 0.01872111 6: (1e+04,1.5e+04] 94.70515 0.02661366 7: (1.5e+04,2e+04] 97.34650 0.02880336
how can make km show number? example, instead of '5e+03' show 5000? thank you.
increase dig.lab
parameter default of 3:
x <- (1:5) * 1e3 cut(x, c(500, 2500, 5000)) #[1] (500,2.5e+03] (500,2.5e+03] (2.5e+03,5e+03] (2.5e+03,5e+03] (2.5e+03,5e+03] #levels: (500,2.5e+03] (2.5e+03,5e+03] cut(x, c(500, 2500, 5000), dig.lab = 4l) #[1] (500,2500] (500,2500] (2500,5000] (2500,5000] (2500,5000] #levels: (500,2500] (2500,5000]
Comments
Post a Comment