17.4 Apply (in base R)
apply family of functions
17.4.1 lapply
17.4.2 sapply
17.4.3 mapply
17.4.4 apply (2-dimensions)
apply(mtcars, MARGIN = 1, mean)
## Mazda RX4 Mazda RX4 Wag Datsun 710
## 29.90727 29.98136 23.59818
## Hornet 4 Drive Hornet Sportabout Valiant
## 38.73955 53.66455 35.04909
## Duster 360 Merc 240D Merc 230
## 59.72000 24.63455 27.23364
## Merc 280 Merc 280C Merc 450SE
## 31.86000 31.78727 46.43091
## Merc 450SL Merc 450SLC Cadillac Fleetwood
## 46.50000 46.35000 66.23273
## Lincoln Continental Chrysler Imperial Fiat 128
## 66.05855 65.97227 19.44091
## Honda Civic Toyota Corolla Toyota Corona
## 17.74227 18.81409 24.88864
## Dodge Challenger AMC Javelin Camaro Z28
## 47.24091 46.00773 58.75273
## Pontiac Firebird Fiat X1-9 Porsche 914-2
## 57.37955 18.92864 24.77909
## Lotus Europa Ford Pantera L Ferrari Dino
## 24.88027 60.97182 34.50818
## Maserati Bora Volvo 142E
## 63.15545 26.26273