# NOT RUN {
if (require("ks", quietly = TRUE)) {
dat <- replicate(2, rnorm(100))
k <- kde(dat)
td <- tidy(k)
head(td)
library(ggplot2)
ggplot(td, aes(x1, x2, fill = estimate)) +
geom_tile() +
theme_void()
# also works with 3 dimensions
dat3 <- replicate(3, rnorm(100))
k3 <- kde(dat3)
td3 <- tidy(k3)
head(td3)
}
# }
Run the code above in your browser using DataLab