comblist2: construct a full list of all combinations of parameters

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/coexist.R

Description

similar to comblist() function

Usage

1
comblist2(parlist)

Arguments

parlist

parlist is a parameter list, can vary on size

Value

return all possible value combinations of the parameter sampling spaces

Author(s)

Youhua Chen <yhchen@zoology.ubc.ca>

References

Chen YH (2012) coexist: an R package for performing species coexistence modeling and analysis under asymmetric dispersal and fluctuating source-sink dynamics. http://code.google.com/p/coexist.

See Also

comblist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (parlist) 
{
    combnum = 1
    parnum <- length(parlist)
    lvector <- vector()
    length(lvector) <- parnum
    for (i in 1:parnum) {
        combnum <- length(parlist[[i]]) * combnum
        lvector[i] = length(parlist[[i]])
    }
    mat <- matrix(0, ncol = parnum, nrow = combnum)
    for (i in 1:parnum) {
        leg <- prod(lvector[i:parnum])/lvector[i]
        repeated = combnum/prod(lvector[i:parnum])
        fullcircle = leg * lvector[i]
        temp <- vector()
        length(temp) <- fullcircle
        for (k in 1:length(parlist[[i]])) {
            temp[((k - 1) * leg + 1):(k * leg)] = parlist[[i]][k]
        }
        for (ii in 1:repeated) {
            mat[((ii - 1) * fullcircle + 1):(ii * fullcircle), 
                i] = temp
        }
    }
    return(mat)
  }

coexist documentation built on May 2, 2019, 1:43 p.m.