calcData | R Documentation |
helper function to calculate a row-wise function (like mean, median etc) across a data.frame
calcData(
data,
setNAZero = NA,
removeNAs = FALSE,
keepData = FALSE,
calcName = "median",
calcFunc = stats::median,
...
)
data |
the data.frame. Note that all rows and columns are used, so selection, filtering, etc should be done beforehand |
setNAZero |
default = NA, when NA this is ignored. Otherwise all cells containing NA will be set to the value of setNAZero. When removeNAs = TRUE, this parameter is ignored |
removeNAs |
default = FALSE, if TRUE all rows containing NA's will be removed via na.omit() |
keepData |
if TRUE, then the original data is returned also |
calcName |
name of the column with the calculated values in it |
calcFunc |
function to be applied row-wise across the data.frame |
... |
serves to pass on "extra" arguments on to the calcFunc function, eg na.rm = TRUE in case of calcFunc = mean |
a data.frame with the calculated values as the only column or with the calculated values as a mew column
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.