ez.2long | R Documentation |
reshape
can handle one (similar to gather(), which does not require index input) or two repetitions
ez.2long(
df,
id,
indexname,
index,
measurename = NULL,
measure = NULL,
drop = NULL,
...
)
id |
unique identification variable, or variable combination |
indexname |
variable name (column to be created) for timing/repetition/index variable, such as "session" |
index |
level name (value labels to be created) for each timing/repetition/index point, such as c("1,2"), c("Pre, Post") |
measurename |
variable name (column/columns to be created) for the measurement, such as "BDI" |
measure |
column names (existing) that are the repeated measures, such as c("BDI_Pre","BDI_Post") |
drop |
variables to drop before reshaping |
returns a new df, label attributes seem to be intact.
refer to my spss syntax 'Time(2) | Measure1(Pre1 Post1) | Measure2(Pre2 Post2) +/- Subject'
if index=c("Pre","Post"), then the character would not be viewed by ez.vx; index=1:2 will be int and fine.
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.2lower()
,
ez.2value()
,
ez.2wide()
,
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()
df <- data.frame(
id = 1:10,
time = as.Date('2009-01-01') + 0:9,
Q3.2.1. = rnorm(10, 0, 1),
Q3.2.2. = rnorm(10, 0, 1),
Q3.2.3. = rnorm(10, 0, 1),
Q3.3.1. = rnorm(10, 0, 1),
Q3.3.2. = rnorm(10, 0, 1),
Q3.3.3. = rnorm(10, 0, 1)
)
ez.2long(df, "id",
"loop_number",c(1:3),
c('Q3.2','Q3.3'),
list(c("Q3.2.1.","Q3.2.2.","Q3.2.3."),c("Q3.3.1.","Q3.3.2.","Q3.3.3.")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.