magrittr
Error: could not find function “%>%”
You need to load a package (like magrittr or dplyr) that defines the function first, then it should work. install.packages(“magrittr”) # package installations are only needed the first time you use it install.packages(“dplyr”) # alternative installation of the %>% library(magrittr) # needs to be run every time you start R and want to use %>% … Read more
What are the differences between R’s new native pipe `|>` and the magrittr pipe `%>%`?
In R 4.1, there was no placeholder syntax for the native pipe. Thus, there was no equivalent of the . placeholder of magrittr and thus the following was impossible with |>. c(“dogs”, “cats”, “rats”) %>% grepl(“at”, .) #[1] FALSE TRUE TRUE As of R 4.2, the native pipe can use _ as a placeholder but … Read more
filter for complete cases in data.frame using dplyr (case-wise deletion)
Try this: df %>% na.omit or this: df %>% filter(complete.cases(.)) or this: library(tidyr) df %>% drop_na If you want to filter based on one variable’s missingness, use a conditional: df %>% filter(!is.na(x1)) or df %>% drop_na(x1) Other answers indicate that of the solutions above na.omit is much slower but that has to be balanced against … Read more