我正在尝试创建一个函数。但不行。你们能帮忙吗?
MyPlot <- function(df, col.name){
summary.df <- ddply(df, .(col.name), summarise,
diff = sum(x1)/sum(x2) - 1,
x3=sum(x3))
summary.df <- melt(summary.df, id.vars= col.name)
p <- (ggplot(data=col.name, aes(x=as.factor(col.name), y=value, group=1,
colour = variable))
+ geom_line()
+xlab(col.name)
+ylab(" ")
+opts(axis.text.x=theme_text(angle=0, hjust=1))
+ggtitle(col.name)
+ facet_grid(variable~., scales="free"))
return(p)
}