. Advertisement .
..3..
. Advertisement .
..4..
I have the following r code, but I do not know how to find the correct result. Why has this problem occurred, and how can it be solved? This is the code I am running:
words <- dtm %>%
as.matrix %>%
colnames %>%
(function(x) x[nchar(x) < 20])
This is the error text I receive:
Error: could not find function "%>%"
Two solutions here: either you install and include the library “magrittr” or the library “dplyr”
To install:
Then, don’t forget to declare it in your script
Windows: If you use %>% within a %dopar% Loop, you must add a reference for loading package
dplyr
(ormagrittr
), whichdplyr
loads.Example:
It will work fine if you don’t use the
.packages
command and instead use%do%
to make it run in one process. It all runs in one process so it doesn’t need to load any new packages.You need to load the package
magrittr
ordplyr
that defines the function. Then it should work.%>%
, a pipe operator, was created to “decrease development times and improve the readability and maintenance of code. ”This code does not use the pipe
%>%
. It would return the exact same code as yours: