我对R很陌生,请耐心等待。在这种情况下,数据并不重要。错误和导致错误的代码如下。我在下面的代码的最后一部分中安装和加载软件包。我的问题是,安装并加载下面列出的软件包是否会导致此错误。我以前用较短的软件包阵容成功地执行了此操作,但是此后丢失了该代码,现在遇到了重命名错误。是否有任何想法是否可以互相抵消?
current %>%
filter(AreaType=="State" & Ownership=="Private" & Industry=="10 Total,
all industries")->current
last %>%
filter(AreaType=="State" & Ownership=="Private" & Industry=="10 Total,
all industries")->last
keepsc <-
c("St","Year","JulyEmployment","AugustEmployment","SeptemberEmployment")
current<- current[keepsc]
keepsl <-
c("St","JulyEmployment","AugustEmployment","SeptemberEmployment")
last<- last[keepsl]
current<- rename(current,
Error in rename(last, JulyEmployment17 = JulyEmployment,
AugustEmployment17 = AugustEmployment, :
unused arguments (JulyEmployment17 = JulyEmployment, AugustEmployment17
=
AugustEmployment, SeptemberEmployment17 = SeptemberEmployment)
#load packages
x = c("tidyverse", "rgdal", "maptools", "mapproj", "rgeos", "plyr",
"RColorBrewer","scales", "viridis", "ggthemes", "tidyverse", "scales",
"cowplot","reshape","reshape2", "plotly")
lapply(x, library, character.only = TRUE)
答案 0 :(得分:5)
是的,程序包的功能具有相同的名称。为了避免这种情况,您可以使用packagename::function()
。
例如MASS
和dplyr
都具有称为select
的相同功能。
### Example working
df <- data.frame('may' = letters[1:4], 'be' = 1:4)
library(dplyr)
df %>% select(may)
## Example not working
detach('package:dplyr', unload = TRUE)
library(dplyr)
library(MASS)
df %>% select(may)