subset.dsm {wordspace} | R Documentation |
Subsetting Distributional Semantic Models (wordspace)
Description
Filter the rows and/or columns of a DSM object according to user-specified conditions.
Usage
## S3 method for class 'dsm'
subset(x, subset, select, recursive = FALSE, drop.zeroes = FALSE,
matrix.only = FALSE, envir = parent.frame(), run.gc = FALSE, ...)
Arguments
x |
an object of class |
subset |
Boolean expression or index vector selecting a subset of the rows; the expression can use variables |
select |
Boolean expression or index vector selecting a subset of the columns; the expression can use variables |
recursive |
if |
drop.zeroes |
if |
matrix.only |
if |
envir |
environment in which the |
run.gc |
whether to run the garbage collector after each iteration of a recursive subset ( |
... |
any further arguments are silently ignored |
Value
An object of class dsm
containing the specified subset of the model x
.
If necessary, counts of nonzero elements for each row and/or column are updated automatically.
Author(s)
Stephanie Evert (https://purl.org/stephanie.evert)
See Also
Examples
print(DSM_TermContext$M)
model <- DSM_TermContext
subset(model, nchar(term) <= 4)$M # short target terms
subset(model, select=(nnzero <= 3))$M # columns with <= 3 nonzero cells
subset(model, nchar(term) <= 4, nnzero <= 3)$M # combine both conditions
subset(model, nchar(term) <= 4, nnzero >= 2)$M # still three columns with nnzero < 2
subset(model, nchar(term) <= 4, nnzero >= 2, recursive=TRUE)$M