reShapeDS {dsBase}R Documentation

reShapeDS (assign function) called by ds.reShape

Description

Reshapes a data frame containing longitudinal or otherwise grouped data from 'wide' to 'long' format or vice-versa

Usage

reShapeDS(data.name, varying.transmit, v.names.transmit, timevar.name,
  idvar.name, drop.transmit, direction, sep)

Arguments

data.name,

the name of the data.frame to be reshaped. Specified via argument <data.name> of ds.reShape function

varying.transmit,

names of sets of variables in the wide format that correspond to single variables in long format (typically what may be called 'time-varying' or 'time-dependent' variables). Specified via argument <varying> of ds.reShape function.

v.names.transmit,

the names of variables in the long format that correspond to multiple variables in the wide format - for example, sbp7, sbp11, sbp15 (measured systolic blood pressure at ages 7, 11 and 15 years). Specified via argument <v.names> of ds.reShape function

timevar.name,

the variable in long format that differentiates multiple records from the same group or individual. Specified via argument <timevar.name> of ds.reShape function

idvar.name,

names of one or more variables in long format that identify multiple records from the same group/individual. This/these variable(s) may also be present in wide format. Specified via argument <idvar.name> of ds.reShape function

drop.transmit,

a vector of names of variables to drop before reshaping. Specified via argument <drop> of ds.reShape function

direction,

a character string, partially matched to either "wide" to reshape from long to wide format, or "long" to reshape from wide to long format. Specified via argument <direction> of ds.reShape function

sep,

a character vector of length 1, indicating a separating character in the variable names in the wide format. Specified via argument <sep> of ds.reShape function

Details

This function is based on the native R function reshape. It reshapes a data frame containing longitudinal or otherwise grouped data between 'wide' format with repeated measurements in separate columns of the same record and 'long' format with the repeated measurements in separate records. The reshaping can be in either direction

Value

a reshaped data.frame converted from long to wide format or from wide to long format which is written to the serverside and given the name provided as the <newobj> argument of ds.reShape or 'newObject' if no name is specified. In addition, two validity messages are returned to the clientside indicating whether <newobj> has been created in each data source and if so whether it is in a valid form (see header for ds.reShape.

Author(s)

Demetris Avraam, Paul Burton for DataSHIELD Development Team


[Package dsBase version 5.0.0 ]