cut function in R- labeling without scientific notations for use in ggplot2

后端 未结 1 1128
既然无缘
既然无缘 2020-11-28 12:40

I use cut and classIntervals to group data in R which I later plot with ggplot2. So a basic operation cutting by quantiles with n=3 would look like this:

lib         


        
相关标签:
1条回答
  • 2020-11-28 13:10

    Use argument dig.lab in cut function:

    a<-c(1,10,100,1000,100000,1000000)
    b<-cut(a, 
    breaks=data.frame(
      classIntervals(
        a,n=3,method="quantile")[2])[,1],
    include.lowest=T,dig.lab=10) ##Number of digits used
    b
    [1] [1,70]          [1,70]          (70,34000]      (70,34000]     
    [5] (34000,1000000] (34000,1000000]
    Levels: [1,70] (70,34000] (34000,1000000]
    
    0 讨论(0)
提交回复
热议问题