MADtraits: Make A Database of Traits

Description Usage Arguments Value Author(s) See Also Examples

View source: R/MADtraits.R

Description

The key function of the MADtraits package. When run with defaults, it will download and build a database of species' traits from all the manuscript sources in the package. *Please* make use the the cache feature, as it will massively speed and ease your use of the package.

Usage

 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
MADtraits(cache, datasets, delay = 5)

## S3 method for class 'MADtraits'
print(x, ...)

## S3 method for class 'MADtraits'
summary(object, ...)

## S3 method for class 'MADtraits'
x[spp, traits]

species(x, ...)

traits(x, ...)

## S3 method for class 'MADtraits'
as.data.frame(
  x,
  row.names,
  optional,
  num.func = mean,
  cat.func = function(x) names(which.max(table(x))),
  data = 10,
  ...
)

Arguments

cache

Specify an existing directory/folder where datasets can be downloaded to and stored. If a dataset is already present in this directory, it will not be downloaded from the server but instead loaded locally. We *STRONGLY* advise you to specify a cache location.

datasets

Character vector of datasets to be searched for trait data. If not specified (the default) all trait datasets will be downloaded and returned.

delay

How many seconds to wait between downloading and processing each dataset (default: 5). This delay may seem large, but if you specify a cache (see above) you only need do it once, and specifying a large delay ensures you don't over-stretch servers. Keeping servers happy is good for you (they won't reject you!) and good for them (they can help everyone).

x

MADtraits object to be printed

...

ignored

object

MADtraits object to be summarised

spp

character vector of species to subset the MADtraits object down to

traits

character vector of traits to subset the MADtraits object down to

row.names

Ignored

optional

Ignored

num.func

To summarise data at the species level (which is done by default), a function is needed to summarise the continuous data at the species level. This argument specifies this function; while the default is mean, you could change this to median or specify your own standard error function.

cat.func

To summarise data at the species level (which is done by default), a function is needed to summarise the continuous data at the species level. This argument specifies this function; while the default is to just return the modal value, other options could be used.

data

Which variables to summarise into a data.frame. If numeric, the top data variables with the most data will be summarised (default: top ten variables). You can also specify variable names if you wish. Note: there are over a thousand variables and over 100,000 species in MADTRAITS - you *do not* want to turn all of this data into a single data.frame, as it will be unmanageable. Subset your data down first to your species or traits of interest (see "examples")

Value

MADtraits.data object.

Author(s)

Will Pearse

See Also

clean.MADtraits convert.MADtraits.units lookup.MADtraits.species

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# Download all MADtraits data, and cache (save) it on your hard-drive for use later
data <- MADtraits(cache="Documents/MADtraits/cache")
# Perform basic checks and cleaning on that data
clean.data <- clean.MADtraits(data)

# Subset data down to the traits you want (notice the comma position)
subset.data <- clean.data[,c("specific_leaf_area","height")]
# Subset data down to the species you want (notice the comma position)
subset.data <- clean.data[c("quercus_robur","quercus_ilex"),]
# Subset multiple things at once
clean.data[c("quercus_robur","quercus_ilex"),"specific_leaf_area"]

# Convert that into a data.frame for use in an analysis
neat.data <- as.data.frame(clean.data)

## End(Not run)

willpearse/natdb documentation built on April 7, 2020, 8:33 a.m.