I'm attempting to follow this working example from the ggplot2 documentation to make a boxplot by specifying the five numbers for a box and whisker plot:
# Using precomputed statistics
# generate sample data
abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
b + geom_boxplot(stat = "identity")
I want to do the same thing with sample data of the form seen in the attached txt (sampledata.txt). My data doesn't have an X1 column and instead has row.names. Ideally I'd like to get the labels for each boxplot from the row.names but I'm not sure how. I attempted to bind a column similar to the X1 column in the example to my data to just get any boxes to show up. However it still didn't work. Below I've included my code and the error I'm getting. The plot that shows up has been attached as a pdf.
> library(ggplot2)
> boxin <- read.table("sampledata.txt", sep="", header = TRUE)
> x1 <- c(1,2,3)
> boxin <- cbind(boxin,x1)
> b <- ggplot(boxin, aes(x = x1, ymin = 'min', lower = 'q1', middle = 'med', upper = q3, ymax = 'max'))
> b + geom_boxplot(stat = "identity")
Warning messages:
1: In Ops.factor(x, from[1]) : - not meaningful for factors
2: In Ops.factor(x, from[1]) : - not meaningful for factors
3: In Ops.factor(x, from[1]) : - not meaningful for factors
4: In Ops.factor(x, from[1]) : - not meaningful for factors
I must be misunderstanding the parameters used in the example or something, as this seems simple enough. Any help would be greatly appreciated!
Melissa