The other, it will be automatically extended to be the same length. There’s no way to list every possible function that you might use, but here’s a selection of functions that are frequently useful:Īrithmetic operators: +, -, *, /, ^. The key property is that the function must be vectorised: it must take a vector of values as input, return a vector with the same number of values as output.
There are many functions for creating new variables that you can use with mutate(). Instead, use rename(), which is a variant of select() that keeps all the variables that aren’t explicitly mentioned: Select() can be used to rename variables, but it’s rarely useful because it drops all of the variables not explicitly mentioned. Learn more about regular expressions in strings. This one matches any variables that contain repeated characters. Matches("(.)\\1"): selects variables that match a regular expression.
Starts_with("abc"): matches names that begin with “abc”.Įnds_with("xyz"): matches names that end with “xyz”.Ĭontains("ijk"): matches names that contain “ijk”. There are a number of helper functions you can use within select(): Let’s dive in and see how these verbs work. Together these properties make it easy to chain together multiple simple steps to achieve a complex result. Using the variable names (without quotes). The subsequent arguments describe what to do with the data frame, These six functions provide the verbs for a language of data manipulation. These can all be used in conjunction with group_by() which changes the scope of each function from operating on the entire dataset to operating on it group-by-group.