suggestPivotFormula: Try to find an appropriate formula to pass to reshape2::dcast

View source: R/widen.R

suggestPivotFormulaR Documentation

Try to find an appropriate formula to pass to reshape2::dcast

Description

The CDISC format can be cumbersome for analysis. The solution would be to transform the data to wide format using the function dcast from the package reshape2. However, as the actual data is not visible, choosing the right widening formula is challenging. This function applies some simple heuristics on the provided parameters and tries to guess a possible formula. This will not be necessarily the best option (and often it will fail completely) - it can still provide a starting point for further refining.

Usage

suggestPivotFormula(what, cols = NULL, by.col = NULL)

Arguments

what

a data.frame

cols

a vector of columns used in the formula. They must exist in 'what' (the previous argument). If null, all the columns from 'what' will be used.

by.col

typically the patient id, the column that will end up as key of the resulting 'wide' data.frame. In most cases this can be left null as it's been set when the package was loaded

Value

a formula (char) that can be (modified and) passed further to the function 'widen'


sib-swiss/dsSwissKnife documentation built on Nov. 27, 2024, 6:03 p.m.