top of page

Integrate / Split Columns

KEY:

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[!is.na(ds$Col2)] <- ds$Col2[!is.na(ds$Col2)]
ds$new[!is.na(ds$Col3)] <- ds$Col3[!is.na(ds$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"]

_____________________________

​

​

bottom of page