Scale and/or center the numeric columns of a data frame or tibble
center_df(data, sc = FALSE, cen = TRUE)
data | A data frame or tibble |
---|---|
sc | Scale the variables (default FALSE) |
cen | Center the variables on their means (default TRUE) |
An object of the same class as `data`, with the numeric columns scaled or centered as requested
Takes a data frame or tibble as input and scales and/or centers the numeric columns. By default, centers but doesn't scale
Kieran Healy
#> # A tibble: 6 x 21 #> country year donors[,1] pop[,1] pop_dens[,1] gdp[,1] gdp_lag[,1] #> <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 Austra… NA NA -22856. -11.8 -6212. -5984. #> 2 Austra… 1991-01-01 -4.39 -22637. -11.8 -5815. -5801. #> 3 Austra… 1992-01-01 -4.13 -22426. -11.8 -5072. -5404. #> 4 Austra… 1993-01-01 -3.97 -22254. -11.8 -4103. -4661. #> 5 Austra… 1994-01-01 -6.23 -22066. -11.8 -3137. -3692. #> 6 Austra… 1995-01-01 -6.30 -21849. -11.8 -1907. -2726. #> # … with 14 more variables: health[,1] <dbl>, health_lag[,1] <dbl>, #> # pubhealth[,1] <dbl>, roads[,1] <dbl>, cerebvas[,1] <dbl>, #> # assault[,1] <dbl>, external[,1] <dbl>, txp_pop[,1] <dbl>, world <chr>, #> # opt <chr>, consent_law <chr>, consent_practice <chr>, consistent <chr>, #> # ccode <chr>