Learn R Programming

umx (version 1.9.1)

umx_scale: Scale data columns, skipping non-scalable columns

Description

umx_scale applies scale to a data.frame. It scale numeric columns, and is smart enough to skip non-scalable columns (string, factor, etc.).

Usage

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

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)

Value

- new dataframe with scaled variables

Details

Also strips-off the attributes which scale adds ("scaled:center" and "scaled:scale" (set attr= TRUE) to keep these.

References

- http://www.github.com/tbates/umx

See Also

umx_scale_wide_twin_data

Other Data Functions: umxCovData, umxFactor, umxHetCor, umxPadAndPruneForDefVars, umx_as_numeric, umx_cont_2_quantiles, umx_cov2raw, umx_long2wide, umx_lower2full, umx_make_MR_data, umx_make_TwinData, umx_make_bin_cont_pair_data, umx_make_fake_data, umx_merge_CIs, umx_read_lower, umx_reorder, umx_residualize, umx_round, umx_scale_wide_twin_data, umx_swap_a_block, umx_wide2long, umx

Examples

Run this code
# NOT RUN {
data(twinData) 
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