Learn R Programming

do (version 1.8.0.0)

reshape_toWide: Reshape to Wide Format

Description

Reshape to Wide Format

Usage

reshape_toWide(
  data,
  key = NULL,
  value = NULL,
  prefix = NULL,
  suffix = NULL,
  sep = "_"
)

Arguments

data

long data

key

column names for key, which can be one or more

value

column names for exchange, which can be one or more

prefix

column names for prefix, which can be one or more

suffix

column names for suffix, which can be one or more

sep

seperation

Value

A wide data.

Examples

Run this code
# NOT RUN {
 df = data.frame(id = c(1,1,2,2,3,3,4,4),
              time = c(1,2,1,2,1,2,1,2),
              w = c(1,6,2,7,3,8,4,9))
 df
 reshape_toWide(data = df,
             key = 'time',
             prefix = 'w')
 df = data.frame(id = c(1,1,2,2,3,3,4,4),
       time = c(1,2,1,2,1,2,1,2),
       w = c(1,6,2,7,3,8,4,9),
       h = c(5,1,6,3,7,5,8,7),
       n = c(2,2,3,3,4,4,5,5))
 df
 reshape_toWide(data = df,
             key = 'time',
             prefix  = c('w','h','n'))
# }

Run the code above in your browser using DataLab