ph_comtrait: comtrait

Description Usage Arguments Details Value Null models Examples

View source: R/comtrait.R

Description

Calculate measures of trait dispersion within each community, and compare observed patterns to those expected under a null model.

Usage

1
2
ph_comtrait(sample, traits, binary = NULL, metric = "variance",
  null_model = 0, randomizations = 999, abundance = TRUE)

Arguments

sample

(data.frame/character) sample data.frame or path to a sample file

traits

(data.frame/character) traits data.frame or path to a traits file

binary

(logical) a logical vector indicating what columns are to be treated as binary characters - all others are treated as continuous

metric

(integer) metric to calculate. One of variance, mpd, mntd, or range (converted to phylocom integer format internally)

null_model

(integer) which null model to use. See Details.

randomizations

(numeric) number of randomizations. Default: 999

abundance

(logical) If TRUE (default) computed accounting for abundance. Otherwise, uses presence-absence.

Details

If you give a data.frame to traits parameter it expects data.frame like

When giving a data.frame to traits make sure to pass in a binary vector for what traits are to be treated as binary.

Value

data.frame of the form:

Null models

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
## Not run: 
sfile <- system.file("examples/sample_comstruct", package = "phylocomr")
tfile <- system.file("examples/traits_aot", package = "phylocomr")

# from files
sample_str <- paste0(readLines(sfile), collapse = "\n")
sfile2 <- tempfile()
cat(sample_str, file = sfile2, sep = '\n')

traits_str <- paste0(readLines(tfile), collapse = "\n")
tfile2 <- tempfile()
cat(traits_str, file = tfile2, sep = '\n')

ph_comtrait(sample = sfile2, traits = tfile2)

# from data.frame
sampledf <- read.table(sfile, header = FALSE,
  stringsAsFactors = FALSE)
traitsdf_file <- system.file("examples/traits_aot_df",
  package = "phylocomr")
traitsdf <- read.table(text = readLines(traitsdf_file), header = TRUE,
  stringsAsFactors = FALSE)
ph_comtrait(sample = sampledf, traits = traitsdf,
  binary = c(FALSE, FALSE, FALSE, TRUE))

## End(Not run)

phylocomr documentation built on Nov. 29, 2018, 9:05 a.m.