Data?  
 Please have a look at https://github.com/hadley/devtools/wiki/Reproducibility 
and/or 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

 I don't see where you are tellling R what data.frame you are using.  
 
p1 <- ggplot(NULL, aes(WUA_discharge,WUA_table)) 
seems to be telling ggplot2 not to use any data.frame and then try to find two 
variables in NULL 

Also WUA_table  is a data.frame [Do str(WUA_table) to see what I mean].AFAIK 
you cannot plot a data.frame in ggplot2.  

Since you did not supply the requested data it is difficult to know for sure 
but it looks to me like you can just work with the original WUA.df.

Here is a quick and dirty example of how to get 'something' that may look a bit 
like what you want. Note "mydata" is a substitute for your WUA.df. 

library(ggplot2)
library(reshape2)
mydata  <-  data.frame(matrix(1:20, ncol = 5))
names(mydata)  <-  letters[1:5]

mdat  <-  melt(mydata, id = "a")
p1 <- ggplot(mdat, aes(a, value, colour = variable)) +
  geom_line() 



it also appears that you are trying to feed ggplot2 a data.frame (WUA_table) 
for the y-axis values




 Please have a look at https://github.com/hadley/devtools/wiki/Reproducibility 
and/or 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example



John Kane
Kingston ON Canada


> -----Original Message-----
> From: zaydfa...@gmail.com
> Sent: Fri, 20 Jun 2014 09:58:56 -0400
> To: r-help@r-project.org
> Subject: [R] zuzufarah Help with ggplot 2 error: Aesthetics must either
> be length one, or the same length as the dataProblems
> 
> WUA_table<-WUA.df[,2:dim(WUA.df)[2]]
> WUA_discharge<-WUA.df[,1]
> colour_scheme<-palette(rainbow(dim(WUA_table)[2]))
> 
> # Main scatterplot
> p1 <- ggplot(NULL, aes(WUA_discharge,WUA_table)) +
>   geom_line() +
>   scale_color_manual(values=colour_scheme)+
>   scale_x_continuous(expand = c(0, 0)) +
>   scale_y_continuous(expand = c(0, 0)) +
>   expand_limits(y = c(min(WUA_table) - .1*diff(range(WUA_table)),
>                       max(WUA_table) + .1*diff(range(WUA_table))))  +
>   expand_limits(x = c(min(WUA_discharge) - .1*diff(range(WUA_discharge)),
>                       max(WUA_discharge) +
> .1*diff(range(WUA_discharge))))
>  +
>   theme(plot.margin= unit(c(0, 0, 0.5, 0.5), "lines"))
> 
> # Get the gtables
> gt1 <- ggplot_gtable(ggplot_build(p1))
> 
> 
> the error message from the following code states:
> Error: Aesthetics must either be length one, or the same length as the
> dataProblems:WUA_table
> 
> the error appears after the line:
> gt1 <- ggplot_gtable(ggplot_build(p1))
> 
> I would appreciate some help on the matter, it seems like a small fix,
> however I am very inexperienced with R!
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
Publish your photos in seconds for FREE
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if4

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to