[R] ggplot2 and facet

Ista Zahn izahn at psych.rochester.edu
Tue Jun 7 22:12:25 CEST 2011


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.
>
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list