I often facet according to a numeric variable, but I want the facet label to be more explanatory than the simple number. I usually create a new label variable that has the numeric value pasted to explanatory text. However, when values have more than one place before the decimal, the first number is used for sorting the factor. Any suggestions to avoid this?
iris[,1:4]<-iris[,1:4]*10
This would work fine for iris, when it does not have more than one value before the decimal.
iris$Petal.Width.label<-paste("Petal.Width=", iris$Petal.Width)
iris$Petal.Width.label<-paste("Petal.Width=", iris$Petal.Width)
qplot(data=iris,
x=Sepal.Length,
y=Sepal.Width,
colour=Species)+facet_wrap(~Petal.Width.label)
Related to:
ggplot: How to change facet labels?
How to change the order of facet labels in ggplot (custom facet wrap labels)