Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rowwise

Computation by rows


Description

Compute on a data frame a row-at-a-time. This is most useful when a vectorised function doesn't exist. Only mutate and summarise are supported so far.

Usage

rowwise_mutate(.data, ...)

rowwise_summarise(.data, ...)

Arguments

.data

A data.table

...

Name-value pairs of expressions

Value

A data.table

See Also

Examples

# without rowwise
df <- data.table(x = 1:2, y = 3:4, z = 4:5)
df %>% mutate(m = mean(c(x, y, z)))
# with rowwise
df <- data.table(x = 1:2, y = 3:4, z = 4:5)
df %>% rowwise_mutate(m = mean(c(x, y, z)))


# # rowwise is also useful when doing simulations
params = fread(" sim n mean sd
  1  1     1   1
  2  2     2   4
  3  3    -1   2")

params %>%
  rowwise_summarise(sim,z = rnorm(n,mean,sd))

tidyft

Tidy Verbs for Fast Data Operations by Reference

v0.4.5
MIT + file LICENSE
Authors
Tian-Yuan Huang [aut, cre] (<https://orcid.org/0000-0002-3591-4203>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.