r - Error: could not find function "%>%" -


i'm using example, going through steps , working far except method below:

 words <- dtm %>%  as.matrix %>%  colnames %>%  (function(x) x[nchar(x) < 20]) 

error: not find function "%>%"

i don't understand benefit of using special operator %>% is, , feedback great.

you need install package magrittr first, should work.

install.packages("magrittr") library(magrittr) 

the pipe operator %>% introduced "decrease development time , improve readability , maintainability of code."

but has decide himself if fits workflow , makes things easier. more information on magrittr, click here.

not using pipe %>%, code return same code:

words <- colnames(as.matrix(dtm)) words <- words[nchar(words) < 20] words 

edit: (i extending answer because of useful comment made @molx)

despite being magrittr, pipe operator more commonly used package dplyr (which requires , loads magrittr), whenever see using %>% make sure shouldn't load dplyr instead.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -