[R-SIG-Mac] Failure using geom_polygon with 2D facet_grid: 1D works

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Mon Jun 13 06:48:52 CEST 2022


This appears to no longer be a Mac problem. Other venues such as StackOverflow, Rstudio help forums or even Rhelp would all be more appropriate. 


If you do decide to send to Rhelp , please read the Posting Guide.  (At the moment you are sending HTML to a plain text mailing list. )
— 
David

Sent from my iPhone

> On Jun 12, 2022, at 4:05 PM, John Helly via R-SIG-Mac <r-sig-mac using r-project.org> wrote:
> 
> Aloha.
> 
> I'm trying to add a state map boundary to a 2D facet_grid in ggplot 
> which plots correlations against principal components (PC).
> 
> The 1D case works but I cannot discover what is causing the failure in 
> the 2D case.  It may be a limit to facet_grid in some way or, more 
> likely, something I don't understand.
> 
> ggplot(A0G, aes(Longitude, Latitude, color=Correlation)) +
> + geom_point(size=2*abs(A0G$Correlation)) +
> + geom_polygon(data = ca_df, aes(x=Longitude, y=Latitude, fill = NA, 
> color = "black")) +
> + facet_grid(rows=vars(A0G$Lag), cols=vars(A0G$PC))
> 
> Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(4L, 3L, 5L, 10L,  :
>   replacement has 11112 rows, data has 516
> 
> The issue seems related to the dimensions of the map df and the data df 
> but I can't grok the problem since it works in the 1D case.
> 
>> dim(ca_df)
> [1] 516   6
> 
>> dim(A0G)
> [1] 11112    18
> 
> Any suggestions welcome.  I'll just keep breaking the problem down if 
> there isn't anything obvious.
> 
> J.
> 
> -- 
> John Helly, University of California, San Diego / San Diego Supercomputer Center / Scripps Institution of Oceanography / 760 840 8660 mobile /http://www.sdsc.edu/~hellyj
> ORCID ID: orcid.org/0000-0002-3779-0603
> 
>    [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list