mix.fun: Apply function to numerical columns of a mixed data.frame...

View source: R/mixtools.R

mix.funR Documentation

Apply function to numerical columns of a mixed data.frame while ignoring non-numeric fields

Description

This function is intended for applying functions to numeric fields of a mixed type data.frame. Namely, the function ignores fields that are e.g. factors, and returns FUN function applied to only the numeric fields.

Usage

mix.fun(x, FUN = scale, ...)

Arguments

x

Data.frame x with mixed type fields

FUN

Function to apply, for example 'scale', 'cov', or 'cor'

...

Additional parameters passed on to FUN

Value

Return values of FUN when applied to numeric columns of 'x'

Author(s)

Teemu Daniel Laajala <teelaa@utu.fi>

See Also

apply

Examples

data(vcapwide)

mix.fun(vcapwide[,c("Group", "PSAWeek4", "PSAWeek10", "PSAWeek14")], FUN=scale) 
# Column 'Group' is ignored
mix.fun(vcapwide[,c("Group", "PSAWeek4", "PSAWeek10", "PSAWeek14")], FUN=cov, use="na.or.complete") 
# ... is used to pass the 'use' parameter to the 'cov'-function

Syksy/hamlet documentation built on Aug. 28, 2023, 6:52 a.m.