Selects target variable and additional columns from a dataframe
target_df.Rd
Selects target variable and additional columns from a dataframe
Arguments
- df
a dataframe
- target_variable
a character string representing the target variable
- ...
additional columns to select from the dataframe
Examples
# Selecting only the target variable
target_df(mtcars, "mpg")
#> mpg
#> Mazda RX4 21.0
#> Mazda RX4 Wag 21.0
#> Datsun 710 22.8
#> Hornet 4 Drive 21.4
#> Hornet Sportabout 18.7
#> Valiant 18.1
#> Duster 360 14.3
#> Merc 240D 24.4
#> Merc 230 22.8
#> Merc 280 19.2
#> Merc 280C 17.8
#> Merc 450SE 16.4
#> Merc 450SL 17.3
#> Merc 450SLC 15.2
#> Cadillac Fleetwood 10.4
#> Lincoln Continental 10.4
#> Chrysler Imperial 14.7
#> Fiat 128 32.4
#> Honda Civic 30.4
#> Toyota Corolla 33.9
#> Toyota Corona 21.5
#> Dodge Challenger 15.5
#> AMC Javelin 15.2
#> Camaro Z28 13.3
#> Pontiac Firebird 19.2
#> Fiat X1-9 27.3
#> Porsche 914-2 26.0
#> Lotus Europa 30.4
#> Ford Pantera L 15.8
#> Ferrari Dino 19.7
#> Maserati Bora 15.0
#> Volvo 142E 21.4
# Selecting the target variable and additional columns
target_df(mtcars, "mpg", cyl, disp)
#> mpg cyl disp
#> Mazda RX4 21.0 6 160.0
#> Mazda RX4 Wag 21.0 6 160.0
#> Datsun 710 22.8 4 108.0
#> Hornet 4 Drive 21.4 6 258.0
#> Hornet Sportabout 18.7 8 360.0
#> Valiant 18.1 6 225.0
#> Duster 360 14.3 8 360.0
#> Merc 240D 24.4 4 146.7
#> Merc 230 22.8 4 140.8
#> Merc 280 19.2 6 167.6
#> Merc 280C 17.8 6 167.6
#> Merc 450SE 16.4 8 275.8
#> Merc 450SL 17.3 8 275.8
#> Merc 450SLC 15.2 8 275.8
#> Cadillac Fleetwood 10.4 8 472.0
#> Lincoln Continental 10.4 8 460.0
#> Chrysler Imperial 14.7 8 440.0
#> Fiat 128 32.4 4 78.7
#> Honda Civic 30.4 4 75.7
#> Toyota Corolla 33.9 4 71.1
#> Toyota Corona 21.5 4 120.1
#> Dodge Challenger 15.5 8 318.0
#> AMC Javelin 15.2 8 304.0
#> Camaro Z28 13.3 8 350.0
#> Pontiac Firebird 19.2 8 400.0
#> Fiat X1-9 27.3 4 79.0
#> Porsche 914-2 26.0 4 120.3
#> Lotus Europa 30.4 4 95.1
#> Ford Pantera L 15.8 8 351.0
#> Ferrari Dino 19.7 6 145.0
#> Maserati Bora 15.0 8 301.0
#> Volvo 142E 21.4 4 121.0