Skip to contents

[Experimental]

  • row_mean() - Calculate the row-wise mean of selected varaibles.

  • row_sum() - Calculate the row-wise sum of selected varaibles.

  • row_max() - Calculate the row-wise maximum of selected varaibles.

  • row_min() - Calculate the row-wise minimum of selected varaibles.

  • row_median() - Calculate the row-wise median of selected varaibles.

  • row_var() - Calculate the row-wise variance of selected varaibles.

  • row_sd() - Calculate the row-wise standard deviation of selected varaibles.

  • row_unique() - Calculate the row-wise number of unique values of selected varaibles.

  • row_miss() - Calculate the row-wise number of missing values of selected varaibles.

  • row_non_miss() - Calculate the row-wise number of non-missing values of selected varaibles.

Usage

row_mean(...)

row_sum(...)

row_max(...)

row_miss(...)

row_non_miss(...)

row_min(...)

row_median(...)

row_var(...)

row_sd(...)

row_unique(...)

Arguments

...

a data frame or tibble, or <tidy-select> within the mutate() function.

Value

A numeric vector.

Examples

tb <- tibble::tibble(
  x = 1:10,
  y = 11:20,
  z = 21:30
)

row_mean(tb)
#> # A tibble: 10 × 1
#>    value
#>    <dbl>
#>  1    11
#>  2    12
#>  3    13
#>  4    14
#>  5    15
#>  6    16
#>  7    17
#>  8    18
#>  9    19
#> 10    20

row_sum(tb)
#> # A tibble: 10 × 1
#>    value
#>    <dbl>
#>  1    33
#>  2    36
#>  3    39
#>  4    42
#>  5    45
#>  6    48
#>  7    51
#>  8    54
#>  9    57
#> 10    60

row_non_miss(tb)
#> # A tibble: 10 × 1
#>    value
#>    <dbl>
#>  1     3
#>  2     3
#>  3     3
#>  4     3
#>  5     3
#>  6     3
#>  7     3
#>  8     3
#>  9     3
#> 10     3

tb %>%
  dplyr::mutate(
    mean = row_mean(x, y),
    sum = row_sum(x, y)
  )
#> # A tibble: 10 × 5
#>        x     y     z  mean   sum
#>    <int> <int> <int> <dbl> <dbl>
#>  1     1    11    21     6    12
#>  2     2    12    22     7    14
#>  3     3    13    23     8    16
#>  4     4    14    24     9    18
#>  5     5    15    25    10    20
#>  6     6    16    26    11    22
#>  7     7    17    27    12    24
#>  8     8    18    28    13    26
#>  9     9    19    29    14    28
#> 10    10    20    30    15    30