Reshaping grouped data via dcast to 'wide' format with rows for each unique combination of group variables. The response are arranged in separate columns for each datum in predictors. If a combination of groups identifies multiple rows, the number of rows in a group is returned to CS for the whole dataset instead of the response variable value.

reshapeWide(
  dataset = cs.in.dataset(),
  preds = cs.in.predictors(),
  resps = cs.in.responses(),
  groups = cs.in.groupvars(),
  auxs = cs.in.auxiliaries(),
  scriptvars = cs.in.scriptvars(),
  return.results = FALSE,
  ...
)

Arguments

dataset

[data.frame]
Dataset with named columns. The names correspond to predictors and responses.

preds

[character]
Character vector of predictor variables.

resps

[character]
Character vector of response variables.

groups

[character]
Character vector of group variables.

auxs

[character]
Character vector of auxiliary variables.

scriptvars

[list]
Named list of script variables set via the Cornerstone "Script Variables" menu. For details see below.

return.results

[logical(1)]
If FALSE the function returns TRUE invisibly. If TRUE, it returns a list of results. Default is FALSE.

...

[ANY]
Additional arguments to be passed to dcast . Please consider possible script variables (scriptvars) to prevent duplicates.

Value

Logical [TRUE] invisibly and outputs to Cornerstone or, if return.results = TRUE, list of resulting data.frame object:

reshapeWide

Dataset with reshaped data.

Details

One script variables is summarized in scriptvars list:

drop

[logical(1)]
Drop missing combinations (TRUE) or include all (FALSE). Default is TRUE.
For details see dcast.

Examples

# Reshape dataset to wide format: reshapeWide(Indometh, "time", "conc", "Subject", character(0) , list(drop = TRUE, aggr.fun = "mean"), return.results = TRUE )
#> $reshapeWide #> time conc_mean_1 conc_mean_4 conc_mean_2 conc_mean_5 conc_mean_6 #> 1: 0.25 1.50 1.85 2.03 2.05 2.31 #> 2: 0.50 0.94 1.39 1.63 1.04 1.44 #> 3: 0.75 0.78 1.02 0.71 0.81 1.03 #> 4: 1.00 0.48 0.89 0.70 0.39 0.84 #> 5: 1.25 0.37 0.59 0.64 0.30 0.64 #> 6: 2.00 0.19 0.40 0.36 0.23 0.42 #> 7: 3.00 0.12 0.16 0.32 0.13 0.24 #> 8: 4.00 0.11 0.11 0.20 0.11 0.17 #> 9: 5.00 0.08 0.10 0.25 0.08 0.13 #> 10: 6.00 0.07 0.07 0.12 0.10 0.10 #> 11: 8.00 0.05 0.07 0.08 0.06 0.09 #> conc_mean_3 #> 1: 2.72 #> 2: 1.49 #> 3: 1.16 #> 4: 0.80 #> 5: 0.80 #> 6: 0.39 #> 7: 0.22 #> 8: 0.12 #> 9: 0.11 #> 10: 0.08 #> 11: 0.08 #>