ez.2wide: reconstruct to wide format, wrapper of 'reshape'

View source: R/frame.R

ez.2wideR Documentation

reconstruct to wide format, wrapper of reshape

Description

reconstruct to wide format, wrapper of reshape

Usage

ez.2wide(df, id, indexname, measure = NULL, drop = NULL, sep = "_", ...)

Arguments

id

unique identification variable, or variable combination

indexname

variable name for timing/repetition/index variable, such as "session"

measure

column names that are the repeated measures, such as c("BDI_Pre","BDI_Post")

drop

variables to drop before reshaping

sep

could be '_acc_'

Value

returns a new df. Because of the structural change, lable attributes would be lost and can NOT be copied with sjmisc_copy_labels–not a subset.

Note

refer to my spss syntax 'SUBJID * Time [School] - Measure2'

See Also

gather, spread, separate, unite
select, slice
distinct, arrange
summarise, count, mutate
group_by, left_join, right_join, inner_join, full_join, semi_join, anti_join
intersect, union, setdiff
bind_rows, bind_cols

Other data transformation functions: ez.2char(), ez.2factor(), ez.2label(), ez.2long(), ez.2lower(), ez.2value(), ez.compute(), ez.del(), ez.label.get(), ez.label.set(), ez.labels.get(), ez.labels.set(), ez.move(), ez.newcol(), ez.num(), ez.recode(), ez.recols(), ez.recol(), ez.rename(), ez.replace(), ez.rncols(), ez.rncol(), ez.select(), ez.sort(), ez.split(), ez.str(), ez.unique(), left_join()

Examples

set.seed(10)
df <- data_frame(
    Person = rep(c("greg", "sally", "sue"), each=2),
    Time = rep(c("Pre", "Post"), 3),
    Score1 = round(rnorm(6, mean = 80, sd=4), 0),
    Score2 = round(jitter(Score1, 15), 0),
    Score3 = 5 + (Score1 + Score2)/2
)
df = data.frame(df)
ez.2wide(df,
        "Person",
        "Time",
        c("Score1","Score2","Score3"))

jerryzhujian9/zmisc documentation built on March 9, 2024, 12:49 a.m.