Your problem is with ecdf... not with ggplot2. I don't know how to
deal with the output from ecdf...
If you run
> ecdf(z)
You get the same error.
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
undefined columns selected
---------- Forwarded message ----------
From: Sarita Paranjpe <
heys...@gmail.com>
Date: Fri, Sep 21, 2012 at 2:53 PM
Subject: Re: qplot
To: Brandon Hurr <
brando...@gmail.com>
Here you go (z) as my_data
On Fri, Sep 21, 2012 at 3:16 PM, Brandon Hurr <
brando...@gmail.com> wrote:
>
> Can you dput(z) so we can see the structure of it and try to plot it?
>
>
> On Fri, Sep 21, 2012 at 1:55 PM, Sarita Paranjpe <
heys...@gmail.com> wrote:
>>
>> Hi,
>> I hope this code makes it more easier to interpret my problem :
>> qplot(unique(l), ecdf(l)(unique(l)), geom='step') # with this command I can plot a single column and show the frequency distribution
>> To plot multiple lines (columns of unequal lengths) this is what I did :
>> a1 = as.matrix(a[,2])
>> b1 = as.matrix(b[,2])
>> c1 = as.matrix(c[,2])
>> d1 = as.matrix(d[,2])
>> e1 = as.matrix(e[,2])
>> cbind.fill<-function(...){
>> nm <- list(...)
>> nm<-lapply(nm, as.matrix)
>> n <- max(sapply(nm, nrow))
>> do.call(cbind, lapply(nm, function (x)
>> rbind(x, matrix(, n-nrow(x), ncol(x)))))
>> }
>> bound = cbind.fill(a1,b1,c1,d1,e1) # this rightfully introduced NAs to fill empty rows
>> y = data.frame(bound)
>> z = melt(y) # creates two columns of variable and value
>> qplot(unique(z), ecdf(z)(unique(z)), geom='step') # doesn't work
>>
>> ## Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) :
>> undefined columns selected
>>
>> ggplot(ecdf(z), aes(x=variable, fill=variable, y=value)) + geom_line() # doesn't work same error as above.
>>
>> Thanks for all your help,
>> SP