Skip to contents

The coder() function applies a set of functions to multiple variables in a data frame using dplyr's mutate() and across() functions.

Usage

coder(.data, .fns)

Arguments

.data

The input data frame.

.fns

A set of functions to be applied to the variables in the data frame.

Value

A modified data frame with the functions applied to the variables.

Examples

# Apply the `mean()` function to multiple variables in the `mtcars` data frame
coder(mtcars, mean)
#>                          mpg    cyl     disp       hp     drat      wt     qsec
#> Mazda RX4           20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Mazda RX4 Wag       20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Datsun 710          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Hornet 4 Drive      20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Hornet Sportabout   20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Valiant             20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Duster 360          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 240D           20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 230            20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 280            20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 280C           20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 450SE          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 450SL          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Merc 450SLC         20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Cadillac Fleetwood  20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Lincoln Continental 20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Chrysler Imperial   20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Fiat 128            20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Honda Civic         20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Toyota Corolla      20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Toyota Corona       20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Dodge Challenger    20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> AMC Javelin         20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Camaro Z28          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Pontiac Firebird    20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Fiat X1-9           20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Porsche 914-2       20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Lotus Europa        20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Ford Pantera L      20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Ferrari Dino        20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Maserati Bora       20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#> Volvo 142E          20.09062 6.1875 230.7219 146.6875 3.596563 3.21725 17.84875
#>                         vs      am   gear   carb
#> Mazda RX4           0.4375 0.40625 3.6875 2.8125
#> Mazda RX4 Wag       0.4375 0.40625 3.6875 2.8125
#> Datsun 710          0.4375 0.40625 3.6875 2.8125
#> Hornet 4 Drive      0.4375 0.40625 3.6875 2.8125
#> Hornet Sportabout   0.4375 0.40625 3.6875 2.8125
#> Valiant             0.4375 0.40625 3.6875 2.8125
#> Duster 360          0.4375 0.40625 3.6875 2.8125
#> Merc 240D           0.4375 0.40625 3.6875 2.8125
#> Merc 230            0.4375 0.40625 3.6875 2.8125
#> Merc 280            0.4375 0.40625 3.6875 2.8125
#> Merc 280C           0.4375 0.40625 3.6875 2.8125
#> Merc 450SE          0.4375 0.40625 3.6875 2.8125
#> Merc 450SL          0.4375 0.40625 3.6875 2.8125
#> Merc 450SLC         0.4375 0.40625 3.6875 2.8125
#> Cadillac Fleetwood  0.4375 0.40625 3.6875 2.8125
#> Lincoln Continental 0.4375 0.40625 3.6875 2.8125
#> Chrysler Imperial   0.4375 0.40625 3.6875 2.8125
#> Fiat 128            0.4375 0.40625 3.6875 2.8125
#> Honda Civic         0.4375 0.40625 3.6875 2.8125
#> Toyota Corolla      0.4375 0.40625 3.6875 2.8125
#> Toyota Corona       0.4375 0.40625 3.6875 2.8125
#> Dodge Challenger    0.4375 0.40625 3.6875 2.8125
#> AMC Javelin         0.4375 0.40625 3.6875 2.8125
#> Camaro Z28          0.4375 0.40625 3.6875 2.8125
#> Pontiac Firebird    0.4375 0.40625 3.6875 2.8125
#> Fiat X1-9           0.4375 0.40625 3.6875 2.8125
#> Porsche 914-2       0.4375 0.40625 3.6875 2.8125
#> Lotus Europa        0.4375 0.40625 3.6875 2.8125
#> Ford Pantera L      0.4375 0.40625 3.6875 2.8125
#> Ferrari Dino        0.4375 0.40625 3.6875 2.8125
#> Maserati Bora       0.4375 0.40625 3.6875 2.8125
#> Volvo 142E          0.4375 0.40625 3.6875 2.8125