Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:54:25+00:00 2026-06-12T10:54:25+00:00

I am writing a function foo(…, lev) on the base of makeContrasts function of

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:54:26+00:00Added an answer on June 12, 2026 at 10:54 am

    A may be over simplifying the problem, but does the following not just work

    foo = function(..., lev) {
     makeContrasts(...,levels =lev)
    }
    
    foo(a + b,b+c, lev =letters[1:3])
    
    
    ## Contrasts
    ## Levels a + b b + c
    ## a     1     0
    ## b     1     1
    ## c     0     1
    

    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. ...

    ct = factor(c("a","b"))
    design = model.matrix(~0+ct)
    colnames(design)=levels(ct)
    makeContrasts(a+b,levels=design) 
    ## Contrasts
    ## Levels a + b
    ##  a     1
    ##  b     1
    foo(a+b, lev = design)
    ## Contrasts
    ## Levels a + b
    ##  a     1
    ##  b     1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass an array parameter to a function in bash, and writing
I am writing function that involve other function from base R with a lot
I am writing a kernel function foo where it takes a structure pointer as
I am writing an R function, and I want to make sure that the
I'm writing a Rails plugin (lets call it Foo). I want it to provide
I was writing a python function that looked something like this def foo(some_list): for
I'm writing a generator function. I want to know if there's a better (read:
I was writing a function foo() which takes 2 const char* s as arguments,
I'm currently writing a function what would create a zip file, which will be
I'm writing a function, which determine the number of useful bits of a 16

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.