切功能R-标签没有科学记数法中使用GGPLOT2(cut function in R- labeli

2019-07-21 23:03发布

我用切割并classIntervals到R基团的数据,我后面GGPLOT2绘制。 因此,一个基本操作由位数削减n = 3的是这样的:

library(classInt)

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)

其中, b是:

[1] [1,70]          [1,70]          (70,3.4e+04]    (70,3.4e+04]    (3.4e+04,1e+06] (3.4e+04,1e+06]
Levels: [1,70] (70,3.4e+04] (3.4e+04,1e+06]

所以该输出的第一行是与我的分组数据的矢量,我可以在使用GGPLOT2。 但是,而不是用科学计数法这个载体,我想的标签为[1,70] (70,34000] (3400,1000000]

我怎样才能achive呢?任何帮助,将不胜感激,也如果你有其他方法,而不是削减和classInt才达到相同的结果。

Answer 1:

使用参数dig.labcut功能:

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]


文章来源: cut function in R- labeling without scientific notations for use in ggplot2