unforge {clickR} | R Documentation |
Un-Forge
Description
Reshapes a data frame from long to wide format
Usage
unforge(data, origin, variables, prefix = origin)
Arguments
data |
data.frame |
origin |
Character vector with variable names in data containing the values to be assigned to the different new variables |
variables |
Variable in data containing the variable names to be created |
prefix |
Vector with prefixes for the new variable names |
Examples
#Data frame in wide format
df1 <- data.frame(id = 1:4, age = c(20, 30, 30, 35), score1 = c(2,2,3,4),
score2 = c(2,1,3,1), score3 = c(1,1,0,1))
df1
#Data frame in long format
df2 <- forge(df1, affixes= c("1", "2", "3"))
df2
#Data frame in wide format again
df3 <- unforge(df2, "score", "time", prefix="score")
[Package clickR version 0.9.39 Index]