Integrate / Split Columns


ds = dataset you are currently using.

DV = dependent variable of interest

IV = independent variable of interest


Subject = name of subject number column 

XYXY = dummy name for a variable, matrix, or data frame into which you are moving information.

Integrate - No identifier column


ds$new <- ds$Col1
ds$new[!$Col2)] <- ds$Col2[!$Col2)]
ds$new[!$Col3)] <- ds$Col3[!$Col3)]


Integrate - With an identifier


ds$New[ds$Condition == "C1"] <-ds$Col1[ds$Condition == "C1"]
ds$New[ds$Condition == "C2"] <-ds$Col1[ds$Condition == "C2"]

ds$New[ds$Condition == "C3"] <-ds$Col1[ds$Condition == "C3"]


Split column in two

Please note: This example "CorrResp", "Old", "New", "ACC", "Hits", and "CR" correspond to information in the above graphic. Adjust as needed.

Translation: When CorrResp is "Old", move accuracy to "Hits" column. When CorrResp is "New", move accuracy to "CR" column.


ds$Hit[ds$CorrResp=="Old"] <-ds$ACC[ds$CorrResp=="Old"]
ds$CR[ds$CorrResp=="New"] <-ds$ACC[ds$CorrResp=="New"]