I am writing a function foo(…, lev) on the base of makeContrasts function of package limma (of bioconductor):
makeContrasts(..., contrasts=NULL, levels)
I want to pass the … argument of foo ‘as-is’ to makeContrasts. Here is my code:
foo = function(..., lev) {
e = substitute(list(...))
makeContrasts(e[[2]], levels=lev)
}
foo(a + b, design)
The reason I have used e[[2]] is that e will be list(a+b) and e[[1]] is list but e[[2]] is what I need: a + b
But the problem is that the actual argument passed to makeContrast is e[[2]] and not a + b.
So what to do?
The complete parameter assignments are as below:
ct = factor(c("a","b"))
design = model.matrix(~0+ct)
colnames(design)=levels(ct)
makeContrasts(a+b,levels=design) # It works
foo(a+b, design) # Does not work
A may be over simplifying the problem, but does the following not just work
using your example
I don’t appear to be oversimplifying.
If
...contain the arguments to be passed to another function, then all you need is to pass...to that function....