Description Usage Arguments Details Value Examples
These functions are used to read several text files and create a data list from them.
1 2 3 4 5 6 7 8 9 10 11 12 | read.multitable(files, dimids, fill = rep(NA, length(files)), ...)
read.multicsv(files, dimids, fill = rep(NA, length(files)), ...)
read.multidelim(files, dimids, fill = rep(NA, length(files)), ...)
read.fourthcorner(community, environment, traits, dimids=c("sites", "species"),
community.name = "abundance", ...)
multifile.choose(n)
read.matrix(...)
|
files |
A character vector with the names of the files containing the tables (possibly created with |
community |
A character string of the name of the file containing the community data of a fourth-corner problem. |
environment |
A character string of the name of the file containing the environment data of a fourth-corner problem. |
traits |
A character string of the name of the file containing the trait data of a fourth-corner problem. |
dimids |
A vector with the names of the columns associated with replication dimensions. For |
fill |
See |
community.name |
Character string of the name of |
n |
Number of files to choose. |
... |
Additional arguments to pass to |
The read.multitable
function is a multiple-table version of read.table
. It is largely a wrapper for dlcast
, so the tables that are read need to produce ‘long’ format data frames. The implementation of read.multitable
is very simple: (1) repeatedly call read.table
to load in the files with names in files
and then (2) call dlcast
to combine these tables into a data list. Therefore, the dimids
and fill
arguments are simply passed to dlcast
.
The read.multicsv
and read.multidelim
simply wrap read.multitable
with the appropriate value for the sep
argument (compare with read.csv
for example).
The read.fourthcorner
function reads in three files (with names passed to community
, environment
, and traits
), and creates a data list out of the resulting files. The community
table is coerced to a matrix
so that the rows and columns are treated as two different dimensions of replication, whereas the other two tables are left as data frames. This function is useful because many community ecologists will store their data in this way.
The multifile.choose
function allows the interactive selection of the names of n
files. Compare with file.choose
.
The read.matrix
function is identical to read.table
but returns a matrix instead of a data frame. The definition of this function is simply a call to read.table
wrapped in a call to as.matrix
.
A data.list
object.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | abundance.file <- tempfile()
environment.file <- tempfile()
trait.file <- tempfile()
abundance <- data.frame(
sites=c(
"midlatitude","subtropical","tropical","equatorial",
"arctic","midlatitude","tropical","equatorial",
"subtropical"
),
species=c(rep("capybara",4),rep("moss",4),"vampire"),
abundance=c(4,10,8,7,5,6,9,3,1)
)
environment <- data.frame(
sites=c(
"arctic","subarctic","midlatitude","subtropical",
"tropical","equatorial"
),
temperature=c(-30,0,10,20,50,30),
precipitation=c(20,40,20,100,150,200)
)
trait <- data.frame(
species=c("capybara","moss","vampire"),
body.size=c(140,5,190),
metabolic.rate=c(20,5,0)
)
write.table(abundance,abundance.file,sep=",")
write.table(environment,environment.file,sep=",")
write.table(trait,trait.file,sep=",")
files <- c(abundance.file,environment.file,trait.file)
dimids <- c("sites","species")
read.multicsv(files,dimids,fill=c(0,NA,NA))
## Modifications necessary to use the read.fourthcorner function
abundance <- data.frame(
capybara = c(4,10,8,7,0,0),
moss = c(6,0,9,3,5,0),
vampire = c(0,1,0,0,0,0),
row.names = c(
"arctic","subarctic","midlatitude","subtropical",
"tropical","equatorial"
)
)
write.table(abundance,abundance.file,sep=",")
read.fourthcorner(abundance.file,environment.file,trait.file,sep=",")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.