tidyverse 干扰 ggplot2?无法访问 map_data

tidyverse interfering with ggplot2? cannot access map_data

运行这些命令在控制台,输出是:

> 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

我可以很好地调用 map_data("county"),直到 tidyverse 被加载,然后它失败了。如何加载 tidyverse 的县地图数据?

测试后转过来上面的评论:

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.

对术语的评论。我的猜测是 "mapping" 的计算机操作实际上是 "multiple application" (函数到中间结果)的缩写。如果有机会回去把它重命名为类似于地理概念的东西,它可能会被命名为 route()-ing。地理 "map" 似乎是静态的二维或三维对象,或者 "mapping" 是此类对象上的位置。

似乎成功了:

# 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