Select first or last rows/columns
Usage
# S3 method for class 'tidymatrix'
slice_head(.data, n, prop, ...)
# S3 method for class 'tidymatrix'
slice_tail(.data, n, prop, ...)Examples
library(dplyr, warn.conflicts = FALSE)
tm <- tidymatrix(big5_responses, big5_respondents, big5_items)
tm |>
activate(rows) |>
slice_head(n = 5)
#> # A tidymatrix: 5 x 30 matrix
#> # Active: rows
#> #
#> # Row data: 5 rows x 8 columns
#> # Column data: 30 rows x 5 columns
#> #
#> # Active data (rows):
#> respondent_id age gender education occupation country life_satisfaction
#> 1 R001 52 Female Secondary Service/Manual EE 8
#> 2 R002 32 Female Master Office FI 4
#> 3 R003 66 Male Bachelor Office EE 6
#> 4 R004 42 Male Bachelor Professional EE 9
#> 5 R005 48 Female Secondary Office FI 8
#> completion_min
#> 1 19.8
#> 2 6.2
#> 3 6.3
#> 4 9.7
#> 5 14.2
tm |>
activate(columns) |>
slice_tail(prop = 0.1)
#> # A tidymatrix: 400 x 3 matrix
#> # Active: columns
#> #
#> # Row data: 400 rows x 8 columns
#> # Column data: 3 rows x 5 columns
#> #
#> # Active data (columns):
#> item_id trait reversed item_text position
#> 1 O4 Openness FALSE I am quick to understand new things. 20
#> 2 O5 Openness TRUE I avoid philosophical discussions. 25
#> 3 O6 Openness TRUE I prefer routine to variety. 30