Skip to content

Instantly share code, notes, and snippets.

@WalkerHarrison
Last active July 27, 2017 16:39
Show Gist options
  • Save WalkerHarrison/9daf9d909c3d88606fcbb8ff4d901d15 to your computer and use it in GitHub Desktop.
Save WalkerHarrison/9daf9d909c3d88606fcbb8ff4d901d15 to your computer and use it in GitHub Desktop.
for (i in x){
wt <- dnorm(x-i, 0, scale)
plt <- ggplot(df, aes(x, y, col = wt)) +
geom_point(size = pmax(100*wt, 1)) +
geom_line(data = smoother[x<=i,], aes(x, y), col = "black") +
geom_point(data = smoother[x==i,], aes(x, y), size = 3,
col = "black", shape = 21, fill = "white") +
scale_color_gradient(low = "dark blue", high = "red") +
theme(legend.position = "none")
ggsave(plt, filename = paste("kernel_", i, ".png", sep=""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment