I think I've stumbled apon my first error with a spelling mistake.
I am running the following code with R and dplyr.
> foobar = c(1,2,3)
> foobar %>% as.character
[1] "1" "2" "3"
This works fine, now I try to run it through an anonymous function.
> foobar %>% function(x) x * 2
Error: Anonymous functions myst be parenthesized
Any idea what is happening? (And where I need to ping to get 'myst' corrected to 'must')?
dplyr is a grammar of data manipulation, providing a consistent set of verbs that help you solve the most common data manipulation challenges: mutate() adds new variables that are functions of existing variables. select() picks variables based on their names. filter() picks cases based on their values.
dplyr is a package for making data manipulation easier. Packages in R are basically sets of additional functions that let you do more stuff in R. The functions we've been using, like str() , come built into R; packages give you access to more functions.
dplyr is a new package which provides a set of tools for efficiently manipulating datasets in R. dplyr is the next iteration of plyr , focussing on only data frames.
This article will cover the five verbs of dplyr: select, filter, arrange, mutate, and summarize.
The error message is quite informative (even if one word is misspelled). Put parentheses around the anonymous function.
foobar <- 1:3
foobar %>% (function(x) x * 2)
# [1] 2 4 6
For explanation, see the Using %>% with call- or function-producing rhs section in
help("%>%", "magrittr")
It has nothing to do with dplyr
. As for the typo in the error message, whenever you find something that might need attention you can contact the package maintainer. Although it seems this has been fixed in the most recent development version of magrittr
. An easy way to find the maintainer of a package is to use
maintainer("magrittr")
The result is omitted here because it contains an email address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With