R stat_density2d NA polygons introduced by coercion

I am using R 3.2.4, ggplot2 2.1.0 and am in error when using stat_density_2d with ggplot (). I can reproduce the error using the example from the ggplot website.

library('ggplot2')
m <- ggplot(faithful, aes(x = eruptions, y = waiting)) + geom_point() +
 xlim(0.5, 6) + ylim(40, 110)
m + stat_density_2d(aes(fill = ..level..), geom = "polygon")

I get only a graph of points, without density contours and the following warning: Warning message: In validDetails.polygon (x): NA, entered by coercion. The dataset has no missing values. I can run another example without errors.

m + geom_density_2d()

I looked at the ggplot GitHub website and did not see any known problems that looked relevant (only some old ones from ~ 2013 that were already resolved). Any ideas?

Thank!

+4
source share
1 answer

I think I found something.

options(stringsAsFactors=F) script, .

, .

+4

All Articles