[R] Alphabetical sequence of data along the x-axis in a box plot

Dan_K dk.aloysius at gmail.com
Thu Oct 13 17:28:47 CEST 2011


The easiest work-around I've found for this problem is to create a vector in
your data frame just using numbers to order them how you want, create a
separate "labeling" data frame with those numbers and corresponding text
labels, and then enter the vector with the grouping names from the labeling
frame in boxplot's 'names' argument. As such:


dir <- "D:\\"
setwd(dir)
data <- read.csv("ODR.csv")
type <- read.csv("soil_type.csv")

boxplot(data=data, Sat..ODR~Type_num, *names=type$Soil.type*, col="light
green", main="ODR by soil type", xlab="Soil type", ylab="ODR")


The labeling data frame should look something like this:

> data.frame(type)
  Type_num Soil.type
1        1       DCL
2        2       UCL
3        3      Sand


Hope this helps!

--
View this message in context: http://r.789695.n4.nabble.com/Alphabetical-sequence-of-data-along-the-x-axis-in-a-box-plot-tp2716131p3901884.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list