I'm using the built in dataset "ChickWeight". For each name, weight, Time, Chick, Diet, my function is simply taking the difference between each pair of names, weight Time, weight Chick, weight Diet, Time Chick, Time Diet, Chick Diet. The function and calculation itself are rather simple and unecesary, but I would like to find how I can pass the 2 parameter function in the combination.
My script is as follows
out <- combn(names(ChickWeight), 2, simplify=FALSE)
f <- function(x, y)
{
diff <- (x - y)
}
mapply(f, out[1,], out[2,])
UPDATE: It seems that I need to subtract the numeric values in my function f, NOT the names. I'm wondering how I may do this. Perhaps I need to find a way to reference out[1,] and out[2,] so that the numeric values in the respective columns can be called upon.