Be aware that the object that aggregate returns with bar() is more complicated than you think. str(aggregate(iris$Sepal.Length, by = list(iris$Species), FUN = bar)) 'data.frame':?? ?3 obs. of? 2 variables: ?$ Group.1: Factor w/ 3 levels "setosa","versicolor",..: 1 2 3 ?$ x????? : num [1:3, 1:2] 5.006 5.936 6.588 0.352 0.516 ... ? ..- attr(*, "dimnames")=List of 2 ? .. ..$ : NULL ? .. ..$ : chr? "mean" "sd" So you get a two column data.frame whose second column is a matrix. [[alternative HTML version deleted]]