Learn R Programming

tidytable (version 0.10.2)

rowwise.: Convert to a rowwise tidytable

Description

Convert to a rowwise tidytable.

Usage

rowwise.(.df)

Arguments

.df

A data.frame or data.table

Examples

Run this code
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)))

# Use c_across() to more easily select many variables
df %>%
  rowwise() %>%
  mutate(row_mean = mean(c_across(x:z))) %>%
  ungroup()

Run the code above in your browser using DataLab