It appears that when I have the sets package installed in my global environment, it affects dplyr and janitor functions from executing correctly. For example, I cannot perform a basic mutate function when it is installed, getting the error "Error in FUN(X[[i]], ...): only defined on a data frame with all numeric variables". To reproduce, see the code below:
EXAMPLE OF SETS ERROR
remove.packages(c("dplyr", "sets"))
install.packages("dplyr")
library(dplyr)
name <- c("Jon", "Bill", "Maria")
age <- c(23, 41, 32)
df <- data.frame(name, age)
data_2 <- df %>%
dplyr::mutate(test = "test")
#looks good
## with sets
remove.packages(c("dplyr", "sets"))
install.packages("dplyr")
install.packages("sets")
library(dplyr)
library(sets)
name <- c("Jon", "Bill", "Maria")
age <- c(23, 41, 32)
df <- data.frame(name, age)
data_2 <- df %>%
dplyr::mutate(test = "test")
That's because sets
package also has a pipe
operator ( %>%
) conflicting with dplyr
's pipe. One way to resolve this is to use conflicted
package . Note the sequence of loading package: sets
package is loaded first and conflict_prefer()
call is right after loading dplyr
.
library(conflicted)
library(sets)
library(dplyr)
conflict_prefer("%>%", "dplyr")
name <- c("Jon", "Bill", "Maria")
age <- c(23, 41, 32)
df <- data.frame(name, age)
data_2 <- df %>%
mutate(test = "test")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.