Q:

how to assign each element of a list as arguments to a function in a loop in R? 

I'm new to R. I'd like to get a number of statistics on the numeric columns (say, column C) of a data frame (dt) based on the combination of factor columns (say, columns A and B).  First, I want the results by grouping both columns A and B, and then the same operations by A alone and by B alone.  I've written a code that looks like the one below.  I have a list of the factor combinations that I'd like to test (groupList) and then for each iteration of the loop I feed an element of that list as the argument to "by".  However, as surely you can see, it doesn't work.  R doesn't recognize the elements of the list as arguments to the function "by".  Any ideas on how to make this work?  Any pointer or suggestion is welcome and appreciated. 
groupList <- list(".(A, B)", "A", "B")

for(i in 1:length(groupList)){
  output <- dt[,list(mean=mean(C),
                     sd=sd(C),
                     min=min(C),
                     median=median(C),
                     max=max(C)),
               by = groupList[i]]

  Here insert code to save each output
}

A:

Your groupList can be restructured as a list of character vectors.  Then you can either use lapply or the existing for loop with an added eval() to interpret the by= input properly:
set.seed(1)
dt <- data.table(A=rep(1:2,each=5), B=rep(1:5,each=2), C=1:10)

groupList <- list(c("A", "B"), c("A"), c("B"))

lapply(
  groupList,
  function(x) {
    dt[, .(mean=mean(C), sd=sd(C)), by=x]
  }
)

out <- vector("list", 3)
for(i in 1:length(groupList)){
  out[[i]] <- dt[, .(mean=mean(C), sd=sd(C)), by=eval(groupList[[i]]) ]
}

str(out)
#List of 3
# $ :Classes ‘data.table’ and 'data.frame':      6 obs.  of  4 variables:
#  ..$ A   : int [1:6] 1 1 1 2 2 2
#  ..$ B   : int [1:6] 1 2 3 3 4 5
#  ..$ mean: num [1:6] 1.5 3.5 5 6 7.5 9.5
#  ..$ sd  : num [1:6] 0.707 0.707 NA NA 0.707 ...
#  ..- attr(*, ".internal.selfref")=<externalptr> 
# $ :Classes ‘data.table’ and 'data.frame':      2 obs.  of  3 variables:
#  ..$ A   : int [1:2] 1 2
#  ..$ mean: num [1:2] 3 8
#  ..$ sd  : num [1:2] 1.58 1.58
#  ..- attr(*, ".internal.selfref")=<externalptr> 
# $ :Classes ‘data.table’ and 'data.frame':      5 obs.  of  3 variables:
#  ..$ B   : int [1:5] 1 2 3 4 5
#  ..$ mean: num [1:5] 1.5 3.5 5.5 7.5 9.5
#  ..$ sd  : num [1:5] 0.707 0.707 0.707 0.707 0.707

