umx (version 4.20.0)

umx_scale: Scale data columns, skipping non-scalable columns

Description

umx_scale applies scale to the columns of a data.frame. By default it scales all numeric columns, and is smart enough to skip non-scalable columns (strings, factors, etc.).

You can also select which columns to convert. This is useful when you want to avoid numeric columns which are actually factors.

note: By default, the attributes which scale adds ("scaled:center" and "scaled:scale" removed to leave nice numeric columns. Set attr= TRUE to preserve these.

Usage

umx_scale(
  df,
  varsToScale = NULL,
  coerce = FALSE,
  attr = FALSE,
  verbose = FALSE
)

Value

  • new dataframe with scaled variables

Arguments

df

A dataframe to scale (or a numeric vector)

varsToScale

(leave blank to scale all)

coerce

Whether to coerce non-numerics to numeric (Defaults to FALSE.

attr

to strip off the attributes scale creates (FALSE by default)

verbose

Whether to report which columns were scaled (default FALSE)

References

See Also

umx_scale_wide_twin_data scale

Other Miscellaneous Stats Functions: FishersMethod(), SE_from_p(), geometric_mean(), harmonic_mean(), oddsratio(), reliability(), umxCov2cor(), umxHetCor(), umxParan(), umxWeightedAIC(), umx_apply(), umx_cor(), umx_means(), umx_r_test(), umx_round(), umx_var(), umx

Examples

Run this code
data(twinData)
# note: this example is here to remind us why scaling independently for each 
# twin would be very bad! Use  umx_scale_wide_twin_data() instead!
df = umx_scale(twinData, varsToScale = c("wt1", "wt2"))
df = umx_scale(twinData,  attr= TRUE)
plot(wt1 ~ wt2, data = df)

Run the code above in your browser using DataLab