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

deletebranch

Delete or Extract a Branch of a Tree


Description

Deletes or extracts a given branch of a tree.

Usage

deletebranch(X, ...)

## S3 method for class 'linnet'
deletebranch(X, code, labels, ...)

## S3 method for class 'lpp'
deletebranch(X, code, labels, ...)

extractbranch(X, ...)

## S3 method for class 'linnet'
extractbranch(X, code, labels, ..., which=NULL)

## S3 method for class 'lpp'
extractbranch(X, code, labels, ..., which=NULL)

Arguments

X

Linear network (object of class "linnet") or point pattern on a linear network (object of class "lpp").

code

Character string. Label of the branch to be deleted or extracted.

labels

Vector of character strings. Branch labels for the vertices of the network, usually obtained from treebranchlabels.

...

Arguments passed to methods.

which

Logical vector indicating which vertices of the network should be extracted. Overrides code and labels.

Details

The linear network L <- X or L <- as.linnet(X) must be a tree, that is, it has no loops.

The argument labels should be a character vector giving tree branch labels for each vertex of the network. It is usually obtained by calling treebranchlabels.

The branch designated by the string code will be deleted or extracted.

The return value is the result of deleting or extracting this branch from X along with any data associated with this branch (such as points or marks).

Value

Another object of the same type as X obtained by deleting or extracting the specified branch.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk

See Also

Examples

# make a simple tree
  m <- simplenet$m
  m[8,10] <- m[10,8] <- FALSE
  L <- linnet(vertices(simplenet), m)
  plot(L, main="")
  # compute branch labels 
  tb <- treebranchlabels(L, 1)
  tbc <- paste0("[", tb, "]")
  text(vertices(L), labels=tbc, cex=2)

  # delete branch B
  LminusB <- deletebranch(L, "b", tb)
  plot(LminusB, add=TRUE, col="green")

  # extract branch B
  LB <- extractbranch(L, "b", tb)
  plot(LB, add=TRUE, col="red")

spatstat.linnet

Linear Networks Functionality of the 'spatstat' Family

v2.1-1
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Ottmar Cronie [ctb], Tilman Davies [ctb], Greg McSwiggan [ctb], Suman Rakshit [ctb]
Initial release
2021-03-28

We don't support your browser anymore

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