1

I'm creating boxplots as follows:

data<-read.table("roughness_elevation.txt",header=T,na.strings="Na")
attach(data)

xle<-expression(Elevation~(m))
xlr<-expression(Roughness)

cvalue2<-cut(value2,breaks=c(1000,1100,1200,1300,1400,1500,1600))

png("G:/Users/.../Desktop/MSC/figures/bproughness.png")
plot(value1~cvalue2,xlab=xle,ylab=xlr,main="",outline=FALSE)
dev.off()

Now (the elevations are between 1000 and 2000 and floats), R is always writting scientific numbers on my x-label. How can I change that?

I tried it with scipen=999 and formatC(..) but none of them worked out (e.g. formatC throws an error because cvalue2 is a factor).

Thanks for your help!

edit:

here are the first rows, there are approximatly 3 million rows:

value1  value2
0.6222  1150.0098
0.6400  1149.3142
0.6364  1148.9984
0.6417  1149.0300
0.6385  1149.6849
0.6475  1150.3357
0.6554  1150.4762
0.6474  1150.4563
Chris
  • 234
  • 1
  • 11
  • Welcome to SO. It looks like you've read the guidelines for posting. One thought though, for an example to be reproducible the data set has to work. You can provided the first n number of rows of your data set, make up a similar example or use one of R's built in data sets. This is more likely to lead to a quick and quality response. – Tyler Rinker Nov 14 '12 at 18:51

1 Answers1

3

Add dig.lab=4 to your cut() function:

cvalue2<-cut(value2,breaks=c(1000,1100,1200,1300,1400,1500,1600), dig.lab=4)

The default is 3 so cut() uses scientific notation to format the ranges. Alternatively you could specify labels at the midpoint of each group:

cvalue2<-cut(value2, breaks=c(1000,1100,1200,1300,1400,1500,1600), 
labels=seq(1050, 1550, by=100))
dcarlson
  • 10,936
  • 2
  • 15
  • 18