read.patchdata: read species abundance data from the patches, an internal...

Description Usage Arguments Author(s) References See Also Examples

View source: R/coexist.R

Description

read species abundance data from the patches, an internal function used by other functions

Usage

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

Arguments

path

local filename for the model output

spnum

species number in the model, default is 2

islandnum

patch number in the model,default is 10

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

batch.read, read.data,

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
##---- 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 = NULL, spnum = 2, islandnum = island) 
{
    if (length(path) != 0) {
        raw <- scan(path, what = character(), sep = "\t")
        fileline <- length(count.fields(path))
        outlist <- list()
        length(outlist) <- fileline/(spnum + 1)
        sp <- matrix(0, nrow = spnum, ncol = islandnum)
        count = 0
        for (i in 1:length(raw)) {
            if (raw[i] == "V1") {
                count = count + 1
                for (j in 1:spnum) {
                  sp[j, ] = as.numeric(raw[(i + 10 + j + (j - 
                    1) * islandnum):(i + 10 + j - 1 + j * islandnum)])
                }
                outlist[[count]] <- list(abund = sp)
            }
        }
    }
    return(outlist)
  }

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