[R] ggplot2 and facet

James Rome jamesrome at gmail.com
Tue Jun 7 23:12:06 CEST 2011


Times is extracted from a larger data frame with the city in it also, so
the variables are not unique. But I tried what you suggested, and get
>     pp2 = qplot(time, error, times)
>     pp2 = pp2 + facet_wrap(~ runway)
>     print(pp2)
Error in eval(expr, envir, enclos) : object 'error' not found

So I am confused.

Thanks,
Jim
On 6/7/2011 4:12 PM, Ista Zahn wrote:

Hi James,
Specify data = times in the qplot call and get rid of times$
everywhere. For example, do

   pp2 = qplot(time, error, data = times)
   pp2 + facet_wrap(~ runway)

Best,
Ista
On Tue, Jun 7, 2011 at 4:01 PM, James Rome <jamesrome at gmail.com> wrote:

> I have a data frame  (attached) that has interpolated EOT errors for
> each minute before flight landing. It also has the runway and an index
> for the flight:
>
>>> times[1:4,]
>  time       error runway flight
> 1    0 -0.02206235    04R      1
> 2    1 -0.07961631    04R      1
> 3    2 -0.13795380    04R      1
> 4    3 -0.20726073    04R      1
>
>>> sapply(times, class)
>     time     error    runway    flight
> "numeric" "numeric"  "factor"  "factor"
>
> I want to plot this using ggplot2
>    library(ggplot2)
>    pp2 = qplot(times$time, times$error, times)
>    pp2 = pp2 + facet_wrap(~ times$runway)
>    print(pp2)
> But when I try it, I get the error
> Error in fix.by(by.x, x) : 'by' must specify valid column(s)
> I get the same error if I make times$time a factor:
>
>>> times$time = as.factor(times$time)
>>> sapply(times, class)
>     time     error    runway    flight
>  "factor" "numeric"  "factor"  "factor"
>
>>>     pp2 = qplot(times$time, times$error, times)
>>>     pp2 = pp2 + facet_wrap(~ times$runway)
>>>     print(pp2)
> Error in fix.by(by.x, x) : 'by' must specify valid column(s)
>
> What am I doing wrong?
>
> And I really want to make a boxplot for every minute of times$time, but
> when I try that, I get one single box.
>
> Thanks for the help,
> Jim
>
>
> ______________________________________________
> R-help at 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.
>
>



More information about the R-help mailing list