convert.filenames: convert saved data sets' names in to a vector based on the...

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

View source: R/coexist.R

Description

convert saved data sets' names in to a vector based on the order of numbers, which will be called by batch.read() function

Usage

1

Arguments

folder

the folder that stored all the model outputs, not a detailed filename

Value

return a vector for each member is a path pointed to a filename (a model output), which can be called by batch.read() function

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, batch.read, read.patchdata

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
##---- 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 (folder) 
{
    files <- list.files(path = folder, full.names = TRUE)
    newf <- vector()
    fnum <- length(files)
    length(newf) <- fnum
    dataorder <- rep(0, 1, fnum)
    for (i in 1:fnum) {
        pos.end <- unlist(gregexpr("00yh", files[i]))[1] - 1
        pos.start <- unlist(gregexpr(paste(folder, "/out", sep = ""), 
            files[i]))[1] + 15
        dataorder[i] <- as.numeric(substr(files[i], pos.start, 
            pos.end))
    }
    for (i in 1:fnum) {
        newf[dataorder[i]] <- files[i]
    }
    newf <- newf[!is.na(newf)]
    return(newf)
  }

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