batch.read: batch read different file data based on the order...

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

View source: R/coexist.R

Description

batch version of read.data() function, can read all the files in a folder

Usage

1
batch.read(path, index = NULL, spnum = 2, islandnum = 10)

Arguments

path

a vector recording all the files in a folder, which can be generated by convert.filenames() function

index

local fielname/path for recording all the parameter combination index matrix generated from make.parcomb() function

spnum

species number in the model, default is 2

islandnum

patch number in the model,default is 10

Details

return a list of data, each list member represents a model output

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

read.data, read.patchdata, make.parcomb

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
##---- 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 (path = pathvector, index = NULL, spnum = 2, islandnum = 10) 
{
    num <- length(path)
    outlist <- list()
    length(outlist) <- num
    if (length(index) == 0) {
        for (i in 1:num) {
            outlist[[i]] <- read.patchdata(path = path[i], spnum = spnum, 
                islandnum = islandnum)
        }
    }
    if (length(index) != 0) {
        for (i in 1:num) {
            outlist[[i]] <- read.data(path = path[i], index = index, 
                spnum = spnum, islandnum = islandnum)
        }
    }
    return(outlist)
  }

Example output

function (path = pathvector, index = NULL, spnum = 2, islandnum = 10) 
{
    num <- length(path)
    outlist <- list()
    length(outlist) <- num
    if (length(index) == 0) {
        for (i in 1:num) {
            outlist[[i]] <- read.patchdata(path = path[i], spnum = spnum, 
                islandnum = islandnum)
        }
    }
    if (length(index) != 0) {
        for (i in 1:num) {
            outlist[[i]] <- read.data(path = path[i], index = index, 
                spnum = spnum, islandnum = islandnum)
        }
    }
    return(outlist)
}

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