Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- growth.plot<-function(data,x,y,fac){
- gp <- ggplot(data = data,aes(x = x, y = y))
- gp <- gp + geom_point() + facet_wrap(~ fac)
- return(gp)
- }
- growth.plot(data=mydata, x=x.var, y=y.var,fac= fac.var)
- gp1 <- ggplot(data = mydata,aes(x = x.var), y = y.var))
- gp1+ geom_point()+ facet_wrap(~ fac.var) # this works
- library(ggplot2)
- make_plot = function(data, x, y, fac) {
- p = ggplot(data, aes_string(x=x, y=y, colour=fac)) +
- geom_point(size=3) +
- facet_wrap(as.formula(paste("~", fac)))
- return(p)
- }
- p = make_plot(iris, x="Sepal.Length", y="Petal.Length", fac="Species")
- ggsave("iris_plot.png", plot=p, height=4, width=8, dpi=120)
Add Comment
Please, Sign In to add comment