Unexpected error message

Showing 1-2 of 3 messages
Unexpected error message Dennis Murphy 1/11/10 6:16 AM
Hi:

While responding to a post on R-help this morning, I used plyr and ggplot2 to do the bulk of the
work, but I kept getting an error message on each plot even though it rendered correctly on the
graphics device.

Here's the input data set I used, in dput form :)

> dput(spikelets2)
structure(list(cn = structure(c(4L, 3L, 5L, 2L, 3L, 6L, 5L, 6L,
4L, 2L, 1L, 1L, 3L, 2L, 1L, 6L, 5L, 2L, 5L, 1L, 4L, 4L, 3L, 6L
), .Label = c("Boomer", "Hereford", "Kranich", "Lans", "Loyal",
"Oakley"), class = "factor"), spl01 = c(1.8, 0.6, 1.1, 0.6, 0.3,
0.5, 1.6, 0.5, 1.4, 1.2, 0.3, 0.2, 0.3, 0.5, 0.3, 0.5, 0.9, 0.7,
0.7, 0.7, 1.9, 1.1, 0.5, 0.1), spl02 = c(3.1, 2.4, 2.7, 2.3,
2.5, 2.1, 3.3, 2.1, 3, 2.7, 2.5, 1.9, 1.1, 2.1, 0.8, 2.7, 2.6,
2.9, 2.3, 2, 3, 2.6, 1.3, 2), spl03 = c(3.5, 3.4, 3.6, 3.3, 3.6,
3.2, 3.9, 3.2, 3.3, 3.6, 3.1, 3, 2.9, 3.1, 2.8, 3.4, 3.6, 3.6,
3.5, 3.3, 3.7, 3.3, 2.9, 3.1), spl04 = c(3.8, 4.2, 3.7, 3.6,
4, 3.4, 4.2, 3.6, 3.8, 3.8, 3.8, 3.4, 3.5, 3.6, 3, 3.8, 3.8,
4, 3.7, 3.5, 3.8, 3.7, 3.8, 3.5), spl05 = c(3.8, 4.5, 4.1, 3.9,
4.4, 3.8, 4.3, 4, 3.9, 4, 3.9, 3.7, 3.9, 3.7, 3.6, 4, 3.8, 4,
3.9, 3.9, 3.9, 4.1, 3.8, 4.1), spl06 = c(4.1, 4.7, 4.4, 4, 4.5,
4.4, 4.4, 4, 4.3, 4, 4.4, 3.9, 4.3, 3.9, 3.7, 3.9, 4.4, 3.9,
3.8, 3.7, 4, 4, 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spl13", "spl14"), row.names = c(1L, 2L, 3L, 6L, 7L, 8L, 9L,
11L, 13L, 14L, 15L, 17L, 21L, 22L, 24L, 25L, 26L, 28L, 30L, 31L,
33L, 34L, 35L, 36L), class = "data.frame")

Here's the code I used:

library(ggplot2)

spikes.long <- melt(spikelets2, id = 'cn')

# Pull out the numeric part of the var names
spikes.long$loc <- as.numeric(substring(spikes.long$variable, 4))
# Poster wanted to separate 'side', where odd was one side and even the other
spikes.long$side <- factor(2 - spikes.long$loc %% 2)
# remove the unnecessary variable term...
spikes.long$variable <- NULL

# Scatterplot by cultivar (cn), coded by color:
p <- qplot(loc, value, data = spikes.long, group = cn,
           colour = side)
p + facet_grid(cn ~ .)

# Paired boxplots by side for each cultivar:
q <- ggplot(spikes.long, aes(side, value))
q + geom_boxplot() + facet_grid(~ cn)

# Scatterplot with smooths for each cultivar:
ggplot(spikes.long, aes(loc, value, colour = cn)) +
    geom_point() + geom_smooth(se = FALSE)

In each of the three plots, I got the error message:

Error in recordGraphics(drawGTree(x), list(x = x), getNamespace("grid")) :
  invalid graphics state

yet all three graphs rendered in the graphics device as expected. As this may
be a possible buglet, I thought I'd report it here.

> sessionInfo()
R version 2.10.1 Patched (2010-01-01 r50884)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252  
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                         
[5] LC_TIME=English_United States.1252   

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods 
[8] base    

other attached packages:
[1] ggplot2_0.8.5   digest_0.4.2    reshape_0.8.3   plyr_0.1.9    
[5] proto_0.3-8     lattice_0.17-26

loaded via a namespace (and not attached):
[1] tools_2.10.1


Dennis
Re: Unexpected error message Hadley Wickham 1/11/10 6:29 AM
Hi Dennis,

Whenever I've encountered this error in the past, it's gone away after
I restarted R.  Does that fix it for you?

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>

--
http://had.co.nz/