Haidar Haidar - 1 year ago 78
R Question

R:Error: could not find function "%>%"

I've just start learning R. I'm using an example, going through the steps and everything is working so far except for this method below:

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

Error: could not find function "%>%"

I actually, I don't understand what is the benefit of using this special char
any feedback would be great, thank you

Answer Source

You need to install the package magrittr first, then it should work. The pipe operator %>% was introduced to "decrease development time and to improve readability and maintainability of code."

But everybody has to decide for himself if it really fits his workflow and makes things easier. For more information on magrittr, click here.

Not using the pipe %>%>, this code would return the same as your code:

words <- colnames(as.matrix(dtm))
words <- words[nchar(words) < 20]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download