In my R shiny App, I want to allow the user, by means of check boxes, to choose columns (instrument parameters in data), and for each of those which functions to apply (i.e. which statistics to apply):
Calculate for columns x,y,z
different functions passed as text strings, selected for that column,
do this per group (factor column with names, called 'category' here.) and
name the resulting columns (name + function-name) in the output df
Selected checkboxes will produce a named list, where the name is the column (parameter name in df), and each named list element contains a vector of text string names of the functions to apply
My list of function requests would look like this:
functionlist <- list(c1 = c('mean', 'sum'),
c2 = 'Length',
c3 = c('Min', 'Max'),
c4 = c('mean', 'sd', 'sum'))
- mean = average value
- Length as in count, or .N
- sd or colSds as in standard deviation
- sum as in total
Therefor I'm looking for a fast was to apply different sets of functions to different columns in 1 go and get the results in the form of a dataframe
The data to apply it to would be comparable to this dummy data:
library(data.table)
n = 100000
dt = data.table(index=1:100000,
category = sample(letters[1:25], n, replace = T),
c1=rnorm(n,10000),
c2=rnorm(n,1000),
c3=rnorm(n,100),
c4 = rnorm(n,10)
)
p.s. it is a follow up of this question: SO question, but now with the extra complication of applying different functions to different columns
UPDATE it would be even nicer if the user can also choose which groups to calculate for.