# 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))
reshape_towide(data = df,
id = 'id',
col_change = '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))
reshape_towide(data = df,
id = 'id',
col_change = c('time','n'),
prefix = 'w',sep = '_')
reshape_towide(data = df,
id = 'id',
col_change = 'time',
prefix = c('w','h'))
reshape_towide(data = df,
id = c('id','n'),
col_change = 'time',
prefix = c('w','h'))
df = data.frame(id = c(1,1,2,2,3,3,4,4),
time = c('a','a','a','b','b','b','c','c'),
n=c(5,5,6,6,7,7,8,8))
reshape_towide(data = df,id = 'id',col_change = 'time')
reshape_towide(data = df,id = c('id','time'),col_change = 'n')
reshape_towide(data = df,id = 'id',col_change = c('time','n'))
# }
Run the code above in your browser using DataLab