Convert to a rowwise tidytable.

rowwise(.df)

Arguments

.df

A data.frame or data.table

Examples

df <- tidytable(x = 1:3, y = 1:3 * 2, z = 1:3 * 3)

# Compute the mean of x, y, z in each row
df %>%
  rowwise() %>%
  mutate(row_mean = mean(c(x, y, z)))
#> # A rowwise tidytable: 3 × 4
#>       x     y     z row_mean
#>   <int> <dbl> <dbl>    <dbl>
#> 1     1     2     3        2
#> 2     2     4     6        4
#> 3     3     6     9        6

# Use c_across() to more easily select many variables
df %>%
  rowwise() %>%
  mutate(row_mean = mean(c_across(x:z))) %>%
  ungroup()
#> # A tidytable: 3 × 4
#>       x     y     z row_mean
#>   <int> <dbl> <dbl>    <dbl>
#> 1     1     2     3        2
#> 2     2     4     6        4
#> 3     3     6     9        6