geom_boxplot arguments imply differing number of rows error

105 views
Skip to first unread message

Rob James

unread,
Sep 17, 2009, 2:22:17 PM9/17/09
to ggp...@googlegroups.com

I am getting the enigmatic "arguments imply differing number of rows"
error out of geom_boxplot.

Appended are 1) the df structure 2) the call to ggplot (and error) and
3) a representative record. The df was read ion from a csv file, but
seems to fine.

I'd welcome suggestions.

Thanks,


Rob


/******* 1

'data.frame': 96302 obs. of 17 variables:
$ age_at_donation: int 21 19 22 20 17 20 22 21 18 21 ...
$ weight : int 125 160 180 140 116 160 130 155 111 140 ...
$ height : int 68 64 64 66 65 62 62 64 66 64 ...
$ pulse : int 100 99 68 77 59 97 73 92 78 82 ...
$ nadler_bv : num 3893 4113 4413 3961 3526 ...
$ firsttime : int 0 1 1 0 0 0 1 1 0 1 ...
$ center3 : int 10 10 10 10 10 10 10 10 10 10 ...
$ mergekey : Factor w/ 32197 levels "","W04100804598500",..: 2 3
4 5 6 7 8 9 10 11 ...
$ racegrp : Factor w/ 6 levels "Asian or Pac Isl, non
Hispanic",..: 6 6 3 6 3 6 3 3 5 3 ...
$ Mild : int 0 0 0 0 0 0 0 0 0 0 ...
$ rxnindicator : int 0 0 0 0 0 0 1 0 0 0 ...
$ PreFaint : int 0 0 0 0 0 0 1 0 0 0 ...
$ LOC : int 0 0 0 0 0 0 0 0 0 0 ...
$ prepost : int 1 1 1 1 1 1 1 1 1 1 ...
$ reactiontype : Factor w/ 5 levels "","Incident",..: 1 1 1 1 1 1 1 1
1 1 ...
$ donationdate : Factor w/ 364 levels "","01apr2007",..: 1 1 1 1 1 1
1 1 1 1 ...
$ pulsegrp : Factor w/ 4 levels "","<65","65-90",..: 1 1 1 1 1 1
1 1 1 1 ...


/****** 2


ggplot(research_master, aes(y = age_at_donation, x=firsttime)) +
geom_boxplot()
Error in data.frame(ymin = 17, ymax = 22, x = 0.5, xmin = 0.05, xmax =
0.95, :
arguments imply differing number of rows: 1, 0

/*** 3
. research_master[15931, ]

age_at_donation weight height pulse nadler_bv firsttime center3
15931 17 210 66 84 5011.01 0 16
mergekey racegrp Mild rxnindicator PreFaint LOC
15931 W04160803349500 White, non Hispanic 0 0 0 0
prepost reactiontype donationdate pulsegrp
15931 1

hadley wickham

unread,
Sep 18, 2009, 11:41:55 AM9/18/09
to Rob James, ggp...@googlegroups.com
Hi Rob,

Could you please make a reproducible example with dput?

Thanks,

Hadley
--
http://had.co.nz/

Rob James

unread,
Sep 22, 2009, 10:35:06 PM9/22/09
to ggp...@googlegroups.com
Sorry, Hadley asked (appropriately) for an example. Seems I can
replicate this error in df(diamonds).

*ggplot(data=diamonds)+geom_boxplot(aes(x=carat, y=price))

*Error in data.frame(y = c(upper, ymax), defaults2) :
arguments imply differing number of rows: 7080, 2

*sessionInfo()*
R version 2.8.1 (2008-12-22)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_CA.UTF-8;LC_NUMERIC=C;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_CA.UTF-8;LC_PAPER=en_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices datasets utils grid methods
[8] base

other attached packages:
[1] foreign_0.8-37 odfWeave_0.7.10 lattice_0.17-25 rattle_2.4.90
[5] pmml_1.2.17 XML_2.6-0 ggplot2_0.8.3 reshape_0.8.3
[9] plyr_0.1.9 proto_0.3-8
>

Rob James

unread,
Sep 22, 2009, 10:49:17 PM9/22/09
to ggp...@googlegroups.com
Mea culpa... Mea maxima culpa...

My R base was the wrong version. A quick fix to sources.list and I'm
back in business.

Thanks!

Rob James

unread,
Sep 23, 2009, 5:10:23 PM9/23/09
to ggp...@googlegroups.com
Well I thought I was back in business, but it turned out only for other
geometries, but not for boxplot... What am I missing here?

> qplot(data=diamonds, x=color, y=price, geom="boxplot")

Error in data.frame(c(9168, 9173, 9173, 9182, 9193, 9199, 9234, 9242, :
arguments imply differing number of rows: 482, 760, 694, 473, 456, 208, 66

and
ggplot(data=diamonds)+geom_boxplot(aes(x=color, y=price))
Error in data.frame(c(9168, 9173, 9173, 9182, 9193, 9199, 9234, 9242, :
arguments imply differing number of rows: 482, 760, 694, 473, 456, 208, 66
> ggplot(data=diamonds)+geom_boxplot(aes(x=factor(color), y=price))
Error in data.frame(c(9168, 9173, 9173, 9182, 9193, 9199, 9234, 9242, :
arguments imply differing number of rows: 482, 760, 694, 473, 456, 208, 66
>

> sessionInfo()
R version 2.9.2 (2009-08-24)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_CA.UTF-8;LC_NUMERIC=C;LC_TIME=en_CA.UTF-8;LC_COLLATE=en_CA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_CA.UTF-8;LC_PAPER=en_CA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_CA.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices datasets utils grid methods
[8] base

other attached packages:
[1] odfWeave_0.7.10 lattice_0.17-25 rattle_2.4.90 pmml_1.2.17
[5] XML_2.6-0 ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9
[9] proto_0.3-8


Reply all
Reply to author
Forward
0 new messages