-1

Assume

group <- c("A0", "A1") then getValue(A1 - A0)

group <- c("A0", "A1", "A2") then getValue(A1 - A0, A2 - A0)

group <- c("A0", "A1", "A2", "A3") then getValue(A1 - A0, A2 - A0, A3 - A0)

If I have group <- c("A0", "A1", ..., "A100") then getValue(A1 - A0, ..., A100 - A0)

I would like to know how to automatically pass the values of group into getValue() like in the above three examples, rather than write them one by one manually?

For example, I have group <- c("A0", "A1", ..., "A1000"), how to pass these values into getValue() function?

Thanks.

  • What are `A0`, `A1`? You can not subtract characters. – Psidom Jan 16 '17 at 03:12
  • `getValue(Map(\`-\`, mget(group[-1]), mget(group[1])))`? You should make your example [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#5963610), though. – alistaire Jan 16 '17 at 03:48
  • I learn this function `makeContrasts {limma}`. Now I know that `contrasts` argument can do the same thing – BioChemoinformatics Jan 16 '17 at 15:23

1 Answers1

0

you might want to use non-standard evaluation via eval, parse

group <- paste0("A", seq_len(101)-1)
cmdstr <- paste0("getValue(", 
    paste(paste(group[-1], group[1], sep=" - "), collapse=", "), 
    ")" )
cmdstr
eval(parse(text=cmdstr))

Just curious, why does the getValue function require increasing number of variables rather than taking in a list?

chinsoon12
  • 25,005
  • 4
  • 25
  • 35