1

Team,

I am trying to get these intervals from scientific notation to normal numbers in the seqcut column.

   seqcut                       non_na_count
1  (1.92e+03,1.94e+03]          333
2  (1.44e+03,1.46e+03]          262
3  (1.7e+03,1.71e+03]           252
4  (1.62e+03,1.64e+03]          239
5  (2e+03,2.01e+03]             206
6  (1.71e+03,1.73e+03]          202
7  (2.03e+03,2.04e+03]          199
8  (1.59e+03,1.61e+03]          195
9  (1.61e+03,1.62e+03]          190
10 (1.82e+03,1.83e+03]          188

i already tried

data3.agg$seqcut = format(data3.agg$seqcut, scientific=F)

and

options(scipen=999)

but it is not working. Any thoughts?

Here is how I created the data :

#Make intervals
seq = seq(from = min(data1$sched_dep_time, na.rm = T), to = max(data1$sched_dep_time, na.rm = T), by = 15)

#make new variables with above intervals
data1$seqcut = cut(data1$sched_dep_time, breaks = seq, include.lowest = T )

Finally, here is some data

 year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time arr_delay carrier flight tailnum origin dest air_time distance hour
839  2013     1   1       NA           1630        NA       NA           1815        NA      EV   4308  N18120    EWR  RDU       NA      416   16
840  2013     1   1       NA           1935        NA       NA           2240        NA      AA    791  N3EHAA    LGA  DFW       NA     1389   19
841  2013     1   1       NA           1500        NA       NA           1825        NA      AA   1925  N3EVAA    LGA  MIA       NA     1096   15
842  2013     1   1       NA            600        NA       NA            901        NA      B6    125  N618JB    JFK  FLL       NA     1069    6
1778 2013     1   2       NA           1540        NA       NA           1747        NA      EV   4352  N10575    EWR  CVG       NA      569   15
     minute           time_hour average_speed on.time.test departed.time.test              seqcut
839      30 2013-01-01 16:00:00            NA           NA               <NA> (1.62e+03,1.64e+03]
840      35 2013-01-01 19:00:00            NA           NA               <NA> (1.92e+03,1.94e+03]
841       0 2013-01-01 15:00:00            NA           NA               <NA>  (1.49e+03,1.5e+03]
842       0 2013-01-01 06:00:00            NA           NA               <NA>           (586,601]
1778     40 2013-01-02 15:00:00            NA           NA               <NA> (1.53e+03,1.55e+03]
  • 3
    It looks like that column is already a factor or a character value. You can't format it as a number any more. You need to go back to where you created those intervals. Did you use `cut()` somewhere? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Oct 17 '19 at 14:38
  • Thats exactly what I did, posted more so I can get your help! – Shehroz Malik Oct 17 '19 at 14:55
  • Related: https://stackoverflow.com/questions/15497694/cut-function-in-r-labeling-without-scientific-notations-for-use-in-ggplot2 – MrFlick Oct 17 '19 at 14:57

1 Answers1

1

This is a feature of cut to make sure labels do not get unwieldy. Use the dig.lab argument to change the sensitivity:

cut(c(1000,1500,2000),breaks=seq(0,2100,100))
[1] (900,1e+03]       (1.4e+03,1.5e+03] (1.9e+03,2e+03]  
21 Levels: (0,100] (100,200] (200,300] (300,400] (400,500] ... (2e+03,2.1e+03]
cut(c(1000,1500,2000),breaks=seq(0,2100,100),dig.lab=4)
[1] (900,1000]  (1400,1500] (1900,2000]
21 Levels: (0,100] (100,200] (200,300] (300,400] (400,500] ... (2000,2100]
James
  • 65,548
  • 14
  • 155
  • 193