mix.fun {hamlet} | R 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
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
[Package hamlet version 0.9.6 Index]