Takes an object of class Basis
and returns an object of class Basis
with selected basis functions removed
Usage
remove_basis(Basis, rmidx)
# S4 method for class 'Basis,ANY'
remove_basis(Basis, rmidx)
# S4 method for class 'Basis,SpatialPolygons'
remove_basis(Basis, rmidx)
See also
auto_basis
for automatically constructing basis functions and show_basis
for visualising basis functions
Examples
library(sp)
df <- data.frame(x = rnorm(10),
y = rnorm(10))
coordinates(df) <- ~x+y
G <- auto_basis(plane(),df,nres=1)
data.frame(G) # Print info on basis
#> loc1 loc2 scale res
#> 1 -1.9123458 -1.6219373 2.286276 1
#> 2 -0.3886904 -1.6219373 2.286276 1
#> 3 1.1349651 -1.6219373 2.286276 1
#> 4 -1.9123458 -0.4025903 2.286276 1
#> 5 -0.3886904 -0.4025903 2.286276 1
#> 6 1.1349651 -0.4025903 2.286276 1
#> 7 -1.9123458 0.8167566 2.286276 1
#> 8 -0.3886904 0.8167566 2.286276 1
#> 9 1.1349651 0.8167566 2.286276 1
#> 10 -1.9123458 2.0361036 2.286276 1
#> 11 -0.3886904 2.0361036 2.286276 1
#> 12 1.1349651 2.0361036 2.286276 1
## Removing basis functions by index
G_subset <- remove_basis(G, 1:(nbasis(G)-1))
data.frame(G_subset)
#> loc1 loc2 scale res
#> 12 1.134965 2.036104 2.286276 1
## Removing basis functions using SpatialPolygons
x <- 1
poly <- Polygon(rbind(c(-x, -x), c(-x, x), c(x, x), c(x, -x), c(-x, -x)))
polys <- Polygons(list(poly), "1")
spatpolys <- SpatialPolygons(list(polys))
G_subset <- remove_basis(G, spatpolys)
data.frame(G_subset)
#> loc1 loc2 scale res
#> 5 -0.3886904 -0.4025903 2.286276 1
#> 8 -0.3886904 0.8167566 2.286276 1