Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

frame2webs

Converts a table of observations into a network matrix


Description

Convenience function to convert a table of observations (typically compiled in a spreadsheet programm) into a network matrix for further use in bipartite.

Usage

frame2webs(dframe, varnames = c("lower", "higher", "webID", "freq"), type.out = 
"list", emptylist = TRUE)

Arguments

dframe

table (i.e. data.frame) of observations, typically simply the data read by one of the read.* functions; see Details for details!

varnames

a vector of characters giving the column names in the table (data.frame) that correspond to

  • species names in lower trophic level (e.g. plants),

  • species names in higher trophic level (e.g. pollinators),

  • the grouping factor for a web (e.g. the site on which interactions were observed)

  • optionally, a fourth column indicating the number of times an interaction was observed (or another link weight that can be summed);

If only three varnames are provided, it is assumed that each observed interaction is in a separate row and frequencies are calculated from the number of rows per link. By default, the names “lower”, “higher”, “webID” and “freq” are used.

type.out

defines the type of output; it could be list (default) or an array with a separate slice for each network. Lists have the advantage that different webs do not have to include all species names, i.e. they can be of different dimensions (ragged). As such they are better suited for webs with non-comparable species sets. An array has the advantage that dimensions are the same, and therefore (i) comparisons can be easily made among webs and (ii) webs can be pooled more easily. The array-option is more suitable for sets of networks from the same community.

emptylist

logical, defaults to TRUE; should, for each network in the list of networks, empty columns and rows be deleted? Since this function first builds an array and from that a list, each network contains all possible links between species of the higher and lower level. When set to TRUE, all species not observed for a given network are removed.

Details

This function supports the easy handling of typical recording that are used to compose a network. The assumed structure of the underlying table is two columns for the names of the lower and higher level species, respectively, one column for a network ID (e.g. site, observer or any other grouping code) and, optionally, a number that indicates how often this interaction was observed. If not given, the number of interactions is simply computed from the number of times the same interaction occurred for each network ID. See example code below.

Typically, data are recorded (in a field book or external data logging device), read into a spreadsheet software (such as MS Excel or Open/LibreOffice Spreadsheet), where names are checked, typos corrected and so forth. This table is then imported into R and aggregated into one or more webs (or an array or a list of webs) using frame2webs.

Each link can have multiple entries or a single entry!

Value

A list or an array of networks, each to be used as input for other bipartite functions.

Note

Great care should be taken in checking species names, slightly different spellings will be assumed to be different species! Common problems occur because a space was added to the name or lower and higher case letters were mixed. For example, R is case sensitive and observes white space, while “Homo sapiens”, “Homo sapiens ” (with a trailing space) and “homo sapiens” are not recognized as different in typical spreadsheet software (e.g. Excel).

Author(s)

Jochen Fründ

See Also

Examples

testdata <- data.frame(higher = c("bee1","bee1","bee1","bee2","bee1","bee3"), 
lower = c("plant1","plant2","plant1","plant2","plant3","plant4"), 
webID = c("meadow","meadow","meadow","meadow","bog","bog"), freq=c(5,1,1,1,3,7))
frame2webs(testdata,type.out="array")
sapply(frame2webs(testdata,type.out="list"), networklevel, index=c("connectance", "C score"))

bipartite

Visualising Bipartite Networks and Calculating Some (Ecological) Indices

v2.16
GPL
Authors
Carsten F. Dormann, Jochen Fruend and Bernd Gruber, with additional code from Stephen Beckett, Mariano Devoto, Gabriel Felix, Jose Iriondo, Tove Opsahl, Rafael Pinheiro, Rouven Strauss and Diego Vazquez, also based on C-code developed by Nils Bluethgen, Aaron Clauset/Rouven Strauss and Miguel Rodriguez-Girones
Initial release
2021-02-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.