Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tidyverse interfering with ggplot2? cannot access map_data

Running these commands in the console, the output is:

> cty0 = ggplot2::map_data("county")
> library(tidyverse)
Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages -----------------------------------------------------------------------------------------------
filter(): dplyr, stats
lag():    dplyr, stats
map():    purrr, maps
> cty0 = ggplot2::map_data("county")
Error: ggplot2 doesn't know how to deal with data of class list

I can call map_data("county") fine until tidyverseis loaded, then it fails. How do I load a county map data with tidyverse loaded?

like image 762
Rafael Avatar asked May 26 '17 15:05

Rafael


1 Answers

Transferred the comment from above after testing:

I'm guessing that the items below the dashed line are from the console messages , but you really should clarify that . Seems likely that the map function in 'purrr' is masking the map function in the 'maps' package. You could reverse the order of loading tidyverse and maps if there were a reason that you needed the (geographic notion of) "mapping" more than you needed the (functional-computer language notion of) "mapping". You probably need to start a new session for that to succeed. The library function checks to see of a package is already loaded and if so does nothing.

A comment on terminology. My guess is that the computer operation of "mapping" is actually a contraction from "multiple application" (of a function to interim results). If there were a chance to go back and rename it to something that would be similar to a geographic concept, it might be named route()-ing. A geographic "map" would seem to be a static two or three-dimensional object or "mapping" to be placement of positions on such an object.

Seems to succeed:

# In a fresh session (and my profile attaches ggplot2 by default)
> library(tidyverse)
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages ---------------------------------
combine():   dplyr, Hmisc  # loaded in my .Rprofile; also attaches gglot2
filter():    dplyr, stats
lag():       dplyr, stats
matches():   dplyr, sos   #from .Rprofile; doesn't seem to clobber findFn function
src():       dplyr, Hmisc
summarize(): dplyr, Hmisc
> cty0 = ggplot2::map_data("county")

Attaching package: ‘maps’

The following object is masked from ‘package:purrr’:

    map
like image 50
IRTFM Avatar answered Nov 02 '22 08:11

IRTFM