Skip to contents

Add or modify columns in the active metadata component. When rows are active, mutates row_data. When columns are active, mutates col_data. Cannot mutate when matrix is active.

Usage

# S3 method for class 'tidymatrix'
mutate(.data, ...)

Arguments

.data

A tidymatrix object

...

Name-value pairs for new or modified columns

Value

A tidymatrix object with mutated metadata

Examples

library(dplyr, warn.conflicts = FALSE)
tm <- tidymatrix(big5_responses, big5_respondents, big5_items)

tm |>
  activate(rows) |>
  mutate(age_group = if_else(age < 40, "young", "older"))
#> # A tidymatrix: 400 x 30 matrix
#> # Active: rows
#> #
#> # Row data: 400 rows x 9 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
#> 6          R006  62 Female     Basic Service/Manual      EE                 4
#>   completion_min age_group
#> 1           19.8     older
#> 2            6.2     young
#> 3            6.3     older
#> 4            9.7     older
#> 5           14.2     older
#> 6           11.6     older