Skip to content

Instantly share code, notes, and snippets.

@nmcglincy
Last active November 13, 2015 19:46
Show Gist options
  • Save nmcglincy/39063b97503c39aeb7a7 to your computer and use it in GitHub Desktop.
Save nmcglincy/39063b97503c39aeb7a7 to your computer and use it in GitHub Desktop.
Took me too long to figure this out...
library(ggplot2)
df = data.frame(foo = rep(c("foo", "bar"), each = 50),
bar = c(rep("tom", 33),
rep("harry", 33),
rep("dick", 34)),
big = runif(n = 100),
small = rnorm(n = 100))
testPlot = function(df, var1, var2) {
ggplot(df,
aes_string(x = "big",
y = "small",
colour = var1,
size = var2)) +
geom_point()
}
testPlot(df = df,
var1 = "foo",
var2 = "bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment