gsGraphDataFrame: Produce a data.frame containing the structure and associated...

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

View source: R/grainscape.R

Description

Given a gsMPG, gsGOC, or any igraph object produce a data.frame containing the node (vertex) and link (edge) structure as well as the associated attributes for these. This provides an easy way to create data tables describing graphs, particularly helpful for users unfamiliar with the structure of igraph objects

Usage

1

Arguments

gsObj

A gsMPG, gsGOC, or igraph object

Value

A list object:

$v giving node (vertex) names and associated attributes
$e giving link (edge) lists and associated attributes

Please see gsMPG and gsGOC for details about the attributes.

For gsGOC objects which typically contain multiple thresholds, an enumerated list of the same length as the number of thresholds is returned each containing $v and $e elements.

Author(s)

Paul Galpern (pgalpern@gmail.com)

References

Fall, A., M.-J. Fortin, M. Manseau, D. O'Brien. (2007) Spatial graphs: Principles and applications for habitat connectivity. Ecosystems. 10:448:461

Galpern, P., M. Manseau, P.J. Wilson. (2012) Grains of connectivity: analysis at multiple spatial scales in landscape genetics. Molecular Ecology 21:3996-4009.

See Also

gsMPG, gsGOC

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
## Not run: 
## Load raster landscape
tiny <- raster(system.file("extdata/tiny.asc", package="grainscape"))

## Create a resistance surface from a raster using an is-becomes reclassification
tinyCost <- reclassify(tiny, rcl=cbind(c(1, 2, 3, 4), c(1, 5, 10, 12)))


## Produce a patch-based MPG where patches are resistance features=1
tinyPatchMPG <- gsMPG(cost=tinyCost, patch=tinyCost==1)

## Extract a representative subset of 5 grains of connectivity
tinyPatchGOC <- gsGOC(tinyPatchMPG, nThresh=5)

## Create a data.frame with the structure and attributes of a gsMPG object
tinyPatchMPG_df <- gsGraphDataFrame(tinyPatchMPG)

## Create a data.frame with the structure and attributes of a gsGOC object
tinyPatchGOC_df <- gsGraphDataFrame(tinyPatchGOC)

## Create a data.frame with the structure and attributes of any igraph object
gsGraphDataFrame(tinyPatchGOC$th[[1]]$goc)


## End(Not run)

grainscape documentation built on May 2, 2019, 6:48 p.m.