Learn R Programming

DImodelsVis (version 1.0.1)

group_prop: Combine variable proportions into groups

Description

Combine variable proportions into groups

Usage

group_prop(data, prop, FG = NULL)

Value

A data-frame with additional columns appended to the end that contain the grouped variable proportions.

Arguments

data

A data frame containing the compositional variables which need to be grouped.

prop

A character/numeric vector indicating the columns containing the compositional variables in `data`.

FG

A character vector of same length as `prop` specifying the group each variable belongs to.

Examples

Run this code
library(DImodels)

data(sim1)

head(group_prop(data = sim1, prop = 3:6,
                FG = c("Gr1", "Gr1", "Gr1", "Gr2")))

head(group_prop(data = sim1, prop = 3:6,
                FG = c("Group1", "Group2", "Group1", "Group3")))

## Data is returned as is, if no groups are specified in FG
head(group_prop(data = sim1, prop = 3:6))

Run the code above in your browser using DataLab