append_sum_line: Append row with column sums

View source: R/append_sum_line.R

append_sum_lineR Documentation

Append row with column sums

Description

Appends a new row with column sums for selected columns. A pretext can be placed on the row.

Usage

append_sum_line(data, column, pretext = "Sum", position = "left")

Arguments

data

[data.frame]
Data to which a row should be appended.

column

[character]
The column names of columns to sum.

pretext

[character(1)]
The explaining text before the sum. Defaults to "Sum".

position

[character(1)]
The position for the pretext, one of c("first", left", "none"). Defaults to "left".

Details

One row is appended to the data frame. The sum is calculated with na.rm = TRUE.

If a tibble, it is transformed to a data frame to avoid errors if the pretext is to be placed in a numeric variable.

Value

data.frame with an appended row with sums.

Author(s)

Petter Hopp Petter.Hopp@vetinst.no

Examples

## Not run: 
# Append row with sum
gris_blodprover_slakteri <- append_sum_line(data = gris_blodprover_slakteri,
                                            column = c("ant_prover"),
                                            pretext = "Sum",
                                            position = "first")

## End(Not run)


NorwegianVeterinaryInstitute/OKplan documentation built on Dec. 20, 2024, 10:41 a.m.