Elena
unread,Jun 7, 2011, 6:19:22 PM6/7/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
Hi,
I've had a lot of trouble adding a smooth geom to my scatterplots.
I've searched through the ggplot2 archive for the answer, but unable
to find one, I thought I'd appeal to the infinite wisdom of the
ggplot2 listserv subscribers. I've already tried method = "gam" from
the mgcv library, which is meant for modelling large datasets. My code
is below.
Thanks in advance,
Elena
#first I took a subset of my data, encompassing 10,000 rows
> small <- Fig1A[sample(nrow(Fig1A), 10000),]
> b <- ggplot(data=small, aes(X.val, Y.val)) + scale_x_log10() + scale_y_log10() + geom_point()
> b
#this appears to work great, but then I run into a problem when I try
to add geom_smooth, as implemented on p. 15 of the ggplot2 book when
working with large dataframes
> b + geom_smooth(method = "gam", formula = y ~ s(x, bs = "cs"), se = TRUE, level = 0.99, alpha = 1, span =0.2)
Error in smooth.construct.cr.smooth.spec(object, data, knots) :
NA/NaN/Inf in foreign function call (arg 1)
#the default also doesn't work:
> b + geom_smooth()
Error in smooth.construct.cr.smooth.spec(object, data, knots) :
NA/NaN/Inf in foreign function call (arg 1)
> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] splines grid stats graphics grDevices utils
datasets
[8] methods base
other attached packages:
[1] foreign_0.8-43 arm_1.4-11 abind_1.3-0
[4] R2WinBUGS_2.1-18 coda_0.14-4 lme4_0.999375-39
[7] Matrix_0.999375-50 lattice_0.19-23 MASS_7.3-12
[10] Hmisc_3.8-3 survival_2.36-5 mgcv_1.7-5
[13] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4
[16] plyr_1.5.2