Learn R Programming

hablar (version 0.2.0)

fun_by_row tidyverse_syntax for funs on rows: row functions inside dplyr mutate

Description

Simple and tidyversish syntac for sum and mean of a row, or select vars. The suffix *_ version of the function removes irrational numbers and NA by default.

Must be used inside the dplyr function mutate in order to work.

Usage

row_sum(..., ignore_na = FALSE, rationalize = FALSE)

row_sum_(..., ignore_na = TRUE, rationalize = TRUE)

row_mean(..., ignore_na = FALSE, rationalize = FALSE)

row_sum_(..., ignore_na = TRUE, rationalize = TRUE)

row_sum(..., ignore_na = FALSE, rationalize = FALSE)

row_mean_(..., ignore_na = TRUE, rationalize = TRUE)

row_mean(..., ignore_na = FALSE, rationalize = FALSE)

Arguments

...

vars or tidyselect function

ignore_na

a logical indicating whether missing values should be removed

rationalize

a logical indicating whether irriational values (NaN, Inf) should be removed

Value

a single numeric vector of the same length as the data frame it is applied to.

See Also

vignette("s"), vignette("hablar")

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
mtcars %>% 
  mutate(sum_of_row = row_sum_(cyl:wt))
  
mtcars %>% 
  mutate(mean_of_row = row_mean(disp, drat, gear))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab