Joh*_*est 2 r scientific-notation
如何摆脱factor变量的默认科学记数法?R当我在当前情况下有 3 个或更多数字时使用它。
我查看了其他答案(scipen和other、format),但它们似乎不适用于factor变量。
然后我在图例中使用这个因子变量,并且我需要整数或定点值。
options(scipen=999)
plot(0,0, type="l", lty=1, lwd=4);
var1 <- c(3334,341,36,341,456)
cut1 <- cut(var1, breaks=2)
cut1<-levels(cut1)
cut1<-gsub(","," - ",cut1)
cut1<-gsub("\\(","[",cut1)
#cut1 <- as.character(cut1);
#formatC(cut1, digits="10", format="f")
cut1
Run Code Online (Sandbox Code Playgroud)
[1]“[32.7 - 1.68e+03]”“[1.68e+03 - 3.34e+03]
我想要这样的东西:
[1]“[32.7 - 1680]”“[1680 - 3340]”
您必须指定您感兴趣的级别的点是一个cut函数。所以最简单的方法是:
cut1 <- cut(var1, breaks=2, dig.lab = 5)
[1] (1685,3337.3] (32.702,1685] (32.702,1685] (32.702,1685] (32.702,1685]
Levels: (32.702,1685] (1685,3337.3]
Run Code Online (Sandbox Code Playgroud)
请参阅 ?cut 了解更多信息。