Re: [R] Problem building up ggplot graph in a loop.

2012-02-16 Thread Keith Weintraub
A kind respondent mentioned that I gave no data for this data set. Here is a subset in CSV format: "","levels","m101","m10" "1",0.15,0.00166736248903737,0.00525782746279257 "2",0.16,0.000671421429082792,0.00263263808833129 "3",0.17,0.00024891450838,0.00125478603676572 "4",0.18,8.627005347

Re: [R] Problem building up ggplot graph in a loop.

2012-02-16 Thread Justin Haynes
ggplot is looking for thisData as a column of coffs. the most 'ggplotesque' way of doing this would be: # melt your data to a "long" format: coffs.melt <- melt(coffs, id.vars = 'levels') # plot using colour aes parameter: ggplot(coffs.melt, aes(x=levels, y=value, colour=variable)) + geom_line()

[R] Problem building up ggplot graph in a loop.

2012-02-16 Thread Keith Weintraub
Folks, I want to automate some graphing using ggplot. Here is my code graphChargeOffs2<-function(coffs) { ggplot(coffs, aes(levels)) dataNames<-names(coffs)[!names(coffs) == "levels"] for(i in dataNames) { thisData<-coffs[[i]] last_plot() + geom_line(aes(y = thisData, colour = i))