Learn R Programming

smint (version 0.4.2)

boundary_Grid: Find boundary points in a Grid object

Description

Find boundary points in a Grid object.

Usage

boundary_Grid(x, type = c("data.frame", "array", "index"))

Arguments

x
An object with class "Grid".
type
The wanted type of result.

Value

An object describing the boundary points. See Details.

Details

When type is "data.frame", the returned object is a data frame containing only the boundary points. When type is "array" the result is a logical array with its elements in correspondence with the index slot of the object. Finally, when type is "index", the result is an integer vector giving the indices of the boundary points in the order of the nodes defined by the object. This order is the one used by the as.data.frame coercion.

Examples

Run this code
## define a Grid object
myGD <- Grid(nlevels = c(3, 4))
bd <- boundary_Grid(myGD, type = "index")

## use a different color for boundary points
cols <- rep("black", length(myGD))
cols[bd] <- "red"
plot(myGD, col = cols, pch = 16, cex = 2, main = "Boundary points")

## repeat this after a generalised transposition
myGD2 <- aperm(myGD, perm = c(2, 1))
bd2 <- boundary_Grid(myGD2, type = "index")
cols2 <- rep("black", length(myGD2))
cols2[bd2] <- "red"
plot(myGD2, col = cols2, pch = 16, cex = 2, main = "Boundary points")

## 3-dimensional
myGD3 <- Grid(nlevels = c("x" = 3, "y"= 4, "z" = 6))
bd3 <- boundary_Grid(myGD3, type = "index")
cols3 <- rep("black", length(myGD3))
cols3[bd3] <- "red"
plot(myGD3, jitter = TRUE, col = cols3, pch = 16, cex = 2, main = "Boundary points")

Run the code above in your browser using DataLab