select - Using select_ and starts_with R -


why doesn't code work?

mtcars %>% select_("starts_with('d')")  error in eval(expr, envir, enclos) : not find function "starts_with" 

this simplified example. trying pass select_ command function.

the difference between select() , select_() non-stadard / standard evaluation of argument. if function starts_with() used argument of select_() should quoted tilde:

library(dplyr) mtcars %>% select_(~starts_with('d')) 

this yields same output normal use of select:

identical(mtcars %>% select_(~starts_with('d')), mtcars %>% select(starts_with('d'))) #[1] true 

for more information see vignette on non-standard evaluation: vignette("nse").


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -