0
votes

I have a data frame with columns that contain data of unequal length that are padded with NA's (i.e., column 1 is 1:136, column 2 is 1:680, column 3 is 1:2380 with the remaining rows filled with NA). I want to create boxplots with the data organized by columns in this data frame. I attempted to use boxplot.matrix:

boxplot.matrix(dataframe,use.cols=TRUE)

But I get the following error:

Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
  'x' must be atomic
In addition: Warning message:
In split.default(c(x), rep.int(1L:ncol(x), rep.int(nrow(x), ncol(x)))) :
  data length is not a multiple of split variable

I'm not sure if the error has to do with needing to handle NA's or if I can't use boxplot.matrix with columns of unequal data counts? Or something completely different? The simple boxplot command works with a comma separated list of each column, but this is unwieldy with a wider data frame.

1
Welcome to Stack Overflow. Can you provide an example we can reproduce? It will be easier to help you. - DJJ
I may be wrong but shouldn't you use boxplot.matrix with matrices, not dataframes?... - Cath

1 Answers

3
votes

it's not clear why you would use boxplot.matrix() with a data frame, as people wrote in the comments. you can either do

boxplot.matrix(as.matrix(dataframe), use.cols = T)

or simply

boxplot(df)