Look at your data.frame with str() and see if the variables you think are numeric are actually factors. is.finite(factor()) reports TRUE but lots of functions expecting numeric data will abort when given factor data.
E.g. library(ggplot2) > d <- data.frame(X=factor(round(sin(1:1000),1)), Y=factor(round(sin((1:1000)*4),1))) > head(d) X Y 1 0.8 -0.8 2 0.9 1 3 0.1 -0.5 4 -0.8 -0.3 5 -1 0.9 6 -0.3 -0.9 > ggplot(d, aes(x=X, y=Y)) + geom_point() + geom_density2d() Error in if (any(h <= 0)) stop("bandwidths must be strictly positive") : missing value where TRUE/FALSE needed > # no contours displayed > ggplot(d, aes(x=as.numeric(as.character(X)), y=as.numeric(as.character(Y)))) + geom_point() + geom_density2d() > # see contours of 2d density If you have factors where you expect numbers then try rereading the file using read.table(colClasses=c("numeric","numeric",...), ...) and look at the missing values to see why they appeared that way. (E.g., does the text file use commas for the decimal points or thousands separators?) Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Jun 30, 2015 at 12:43 PM, Chichi Shu <chichi....@hotmail.com> wrote: > Dear Listers > > > > I’ve been using ggmap package to produce crime Heat map. But I’ve noticed > the following warning message when executing my code: > > > > In loop_apply(n, do.ply) : > > Removed 4945 rows containing non-finite values (stat_density2d). > > > > I’ve googled this message but I couldn’t find any good answers. > > > > Is this related to ggmap package or one of its depending package? > > > > What does it mean? > > > > Thanks! > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.