ez.2wide | R Documentation |
reshape
reconstruct to wide format, wrapper of reshape
ez.2wide(df, id, indexname, measure = NULL, drop = NULL, sep = "_", ...)
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_' |
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.
refer to my spss syntax 'SUBJID * Time [School] - Measure2'
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()
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.