[R] ggplot2 and facet
Ista Zahn
izahn at psych.rochester.edu
Tue Jun 7 23:21:48 CEST 2011
Hi James,
On Tue, Jun 7, 2011 at 5:12 PM, James Rome <jamesrome at gmail.com> wrote:
> 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
That is _not_ what I suggested. I said
pp2 = qplot(time, error, data = times)
pp2 + facet_wrap(~ runway)
You are missing the data = part.
>
> 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.
>>
>>
>
>
>
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org
More information about the R-help
mailing list