filterSpataObject | R Documentation |
This function filters a SPATA2 object based on specified logical expressions,
retaining only the observations that meet the criteria. It has the same effect as
the function subsetSpataObject()
has, but it provides more convenient input options.
Note the .
prefix before the arguments.
filterSpataObject(
object,
...,
.normalize = FALSE,
.spatial_proc = TRUE,
.verbose = TRUE
)
object |
An object of class |
... |
< |
.normalize |
Logical value indicating whether numeric variables should be
scaled to 0-1 before filtering. Default is |
.spatial_proc |
Logical value. Indicates whether the new sub-object is
processed spatially. If If |
.verbose |
Logical. If (Warning messages will always be printed.) |
The function filters the input SPATA2
object based on the logical expressions provided in ...
.
If no expressions are provided, the function returns the input object with a warning.
The variables used in the expressions are extracted and joined with the SPATA2
object's data frame.
The observations that meet the criteria specified by the logical expressions are retained.
The updated input object, containing the added, removed or computed results.
joinWithVariables()
, subsetSpataObject()
library(SPATA2)
library(patchwork)
object <- loadExampleObject("UKF269T", process = TRUE, meta = TRUE)
orig_frame <- ggpLayerFrameByCoords(object)
# exemplifies the effect of the 'normalize'
# note the value range
plotSurface(object, color_by = "SNAP25", normalize = TRUE)
plotSurface(object, color_by = "SNAP25", normalize = FALSE)
# another grouping variable for this example
plotSurface(object, color_by = "bayes_space")
# example 1: normalize = TRUE
object_sub1 <- filterSpataObject(object, SNAP25 > 0.5, .normalize = TRUE)
plotSurface(object_sub1) +
(plotSurface(object_sub1) + orig_frame)
# example 2: normalize = FALSE
object_sub2 <- filterSpataObject(object, SNAP25 > 0.5, .normalize = FALSE)
plotSurface(object_sub2, color_by = "SNAP25") +
(plotSurface(object_sub1) + orig_frame)
# example 3: logical tests can be more complex
object_sub3 <- filterSpataObject(object, GFAP > 0.5 | bayes_space %in% c("1", "3"), .normalize = TRUE)
plotSurface(object_sub3, color_by = "SNAP25") +
plotSurface(object_sub3, color_by = "bayes_space")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.