How to rid of default scientific notation for factor
variable? It is used by R
when I have 3 or more digits in the current case.
I looked through other answers (scipen and other, format), but it seems they do not work for factor
variables.
I use then this factor variable in the legend, and I need integer or fixed point values.
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
[1] " [32.7 - 1.68e+03]" "[1.68e+03 - 3.34e+03]
And I want something like that:
[1] " [32.7 - 1680]" "[1680 - 3340]"
The point where you have to specify what levels you are interested in, is a cut
function. So easiest way is:
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]
See ?cut for more information.