| GraphSpace-accessors | R Documentation |
Access and modify individual components of a GraphSpace object.
## S4 method for signature 'GraphSpace'
names(x)
## S4 method for signature 'GraphSpace'
gs_names(x)
## S4 method for signature 'GraphSpace'
gs_nodes(x, ...)
## S4 method for signature 'GraphSpace'
gs_edges(x, ...)
## S4 method for signature 'GraphSpace'
gs_image(x)
## S4 replacement method for signature 'GraphSpace'
gs_image(x) <- value
## S4 method for signature 'GraphSpace'
gs_image_maxpixels(x)
## S4 replacement method for signature 'GraphSpace'
gs_image_maxpixels(x) <- value
## S4 method for signature 'GraphSpace'
gs_graph(x)
## S4 method for signature 'GraphSpace'
gs_fdata(x)
## S4 replacement method for signature 'GraphSpace'
gs_fdata(x) <- value
## S4 method for signature 'GraphSpace'
gs_nfeatures(x)
## S4 method for signature 'GraphSpace'
gs_features(x)
## S3 method for class 'GraphSpace'
as.igraph(x, ...)
## S4 method for signature 'GraphSpace'
gs_vcount(x)
## S4 method for signature 'GraphSpace'
gs_ecount(x)
## S4 method for signature 'GraphSpace'
gs_scale_factor(x)
## S4 replacement method for signature 'GraphSpace'
gs_scale_factor(x) <- value
## S4 method for signature 'GraphSpace'
gs_geometry(x, name = "geometry")
## S4 replacement method for signature 'GraphSpace'
gs_geometry(x, name = "geometry") <- value
## S4 method for signature 'GraphSpace'
x$name
## S4 replacement method for signature 'GraphSpace'
x$name <- value
x |
A GraphSpace class object |
... |
Additional arguments passed to extraction methods. |
value |
Replacement value for the selected slot or attribute. |
name |
Name of the attribute. |
For gs_nodes(), the optional vars argument specifies
node-associated features retrieved from the fdata
container. See also gs_fetch_features.
Updated GraphSpace object.
gs_fetch_features
library(RGraphSpace)
library(igraph)
# Load a demo igraph
data('gtoy1', package = 'RGraphSpace')
# Create a new GraphSpace object
gs <- GraphSpace(gtoy1)
#--- Usage of GraphSpace accessors:
# Vertex names
names(gs)
# Vertex attribute names
gs_names(gs)
# Get a data frame with nodes
gs_nodes(gs)
# Get a data frame with edges
gs_edges(gs)
# Get an igraph object
gs_graph(gs)
# Get a data frame with nodes
gs_nodes(gs)
# Vertex count
gs_vcount(gs)
# Edge count
gs_ecount(gs)
# Images may be provided as raster or numeric matrices;
# 'SpatRaster' objects are supported when the optional
# 'terra' package is available
gs_image(gs) <- as_colorraster(volcano)
# Apply a scaling factor to node coordinates
gs_scale_factor(gs) <- 0.1
# Undo scaling
gs_scale_factor(gs) <- 1
# Set a pixel budget for image operations
gs_image_maxpixels(gs) <- 4e+06
# Normalize image and node coordinates to graph space
gs <- normalizeGraphSpace(gs, image.space = FALSE)
# Add a sparse Matrix aligned to nodes
library(Matrix)
mtx <- Matrix(0, gs_vcount(gs), 2)
rownames(mtx) <- names(gs)
colnames(mtx) <- c("feature1","feature2")
gs_fdata(gs) <- mtx
# Feature names
gs_features(gs)
# Feature count
gs_nfeatures(gs)
# Add an 'sfc' geometry column (requires the optional 'sf' package)
if (requireNamespace("sf", quietly = TRUE)) {
gs_geometry(gs) <- sfshape_ngons(n = gs_vcount(gs))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.