Posts

Showing posts from July, 2021

Using across function in R | dplyr package

AGRON Info-Tech July 13, 2021 Introduction Data modification across multiple columns A purrr-style formula Named list of functions Filtering the output Introduction The across() function in dplyr package allows you to utilize select() semantics within “data-masking” methods like summarise() and modify() to apply the same modification to several columns. By restricting your options, the dplyr package makes these processes quick and straightforward, and it helps you think about your data manipulation issues. The function across() supercedes the other scoped variants such as summarise_at(), summarise_if() and summarise_all(). Let’s look at some examples of how to apply the across() function and how it may be used to change data. Load the package dplyr by using library() or require() function. library (dplyr) We shall use the iris data set to apply a