For a dfm object, returns the first or last n
documents
and first nfeature
features.
# S3 method for dfm head(x, n = 6L, nfeature = 6L, ...) # S3 method for dfm tail(x, n = 6L, nfeature = 6L, ...)
x | a dfm object |
---|---|
n | a single, positive integer. If positive, size for the resulting object: number of first/last documents for the dfm. If negative, all but the n last/first number of documents of x. |
nfeature | the number of features to return, where the resulting object
will contain the first |
... | additional arguments passed to other functions |
A dfm class object corresponding to the subset defined
by n
and nfeature
.
head(data_dfm_lbgexample, 3, nfeature = 5)#> Document-feature matrix of: 3 documents, 5 features (66.7% sparse). #> 3 x 5 sparse Matrix of class "dfmSparse" #> features #> docs A B C D E #> R1 2 3 10 22 45 #> R2 0 0 0 0 0 #> R3 0 0 0 0 0head(data_dfm_lbgexample, -4)#> Document-feature matrix of: 2 documents, 6 features (41.7% sparse). #> 2 x 6 sparse Matrix of class "dfmSparse" #> features #> docs A B C D E F #> R1 2 3 10 22 45 78 #> R2 0 0 0 0 0 2tail(data_dfm_lbgexample)#> Document-feature matrix of: 6 documents, 6 features (80.6% sparse). #> 6 x 6 sparse Matrix of class "dfmSparse" #> features #> docs ZF ZG ZH ZI ZJ ZK #> R1 0 0 0 0 0 0 #> R2 0 0 0 0 0 0 #> R3 0 0 0 0 0 0 #> R4 2 0 0 0 0 0 #> R5 78 45 22 10 3 2 #> V1 0 0 0 0 0 0tail(data_dfm_lbgexample, n = 3, nfeature = 4)#> Document-feature matrix of: 3 documents, 4 features (66.7% sparse). #> 3 x 4 sparse Matrix of class "dfmSparse" #> features #> docs ZH ZI ZJ ZK #> R4 0 0 0 0 #> R5 22 10 3 2 #> V1 0 0 0 0