create_node_labels {chessboard}R Documentation

Create unique node labels

Description

Creates unique node (sampling units) labels in directed (or undirected) spatial (or not) networks.

It's important to note that, even the package chessboard is designed to deal with spatial networks, it does not explicitly use spatial coordinates. Every functions of the package will use the node labels.

To work, the package chessboard requires that the sampling has two dimensions: one from bottom to top (called quadrats), and one from left to right (called transects). If the sampling has been conducted along one single dimension (transects or quadrats), this function will create a fictitious label for the missing dimension. In other words, the package chessboard can work with sampling designs such as regular grids (two dimensions), transects (one dimension), and quadrats (one dimension).

In addition, the package can also deal with multiple locations. In that case, users will need to use the argument location.

The node labels will be of the form: 1-2, where 1 is the identifier of the transect (created by the function if missing), and 2, the identifier of the quadrat (created by the function if missing).

Usage

create_node_labels(data, location, transect, quadrat)

Arguments

data

a data.frame with at least one column, 'transect' or 'quadrat'. If only one column is provided and transect or quadrat is NULL, the network will be considered as one-dimensional. If data contains both 'transect' and 'quadrat' columns, the network will be considered as two-dimensional. The data.frame can contain additional columns.

location

a character of length 1. The name of the column that contains location identifiers. If missing (or NULL), a unique location identifier will be created and named 1 (for the purpose of the package only). This argument is optional if the sampling ha been conducted at one location, but required if the survey is structured in multiple locations.

transect

a character of length 1. The name of the column that contains transect identifiers. If missing (or NULL), a unique transect identifier will be created and named 1 (for the purpose of the package only). If missing, the network will be considered as one-dimensional.

quadrat

a character of length 1. The name of the column that contains quadrat identifiers. If missing (or NULL), a unique quadrat identifier will be created and named 1 (for the purpose of the package only). If missing, the network will be considered as one-dimensional.

Value

A data.frame with at least the four following columns:

Examples

library("chessboard")

# Two-dimensional sampling ----
sites_infos <- expand.grid("transect" = 1:3, "quadrat" = 1:5)
sites_infos

nodes <- create_node_labels(data     = sites_infos, 
                            transect = "transect", 
                            quadrat  = "quadrat")
nodes

gg_chessboard(nodes)

# One-dimensional sampling (only transects) ----
transects_only <- data.frame("transect" = 1:5)

nodes <- create_node_labels(transects_only,
                            transect = "transect")
nodes

gg_chessboard(nodes)

# One-dimensional sampling (only quadrats) ----
quadrats_only <- data.frame("quadrat" = 1:5)

nodes <- create_node_labels(quadrats_only,
                            quadrat = "quadrat")
nodes

gg_chessboard(nodes)

[Package chessboard version 0.1 Index]