Hi!
I don't know anything about the behavior of casestovars
(or any other command in SPSS for that matter), but to get your desired output, you could add a ConditionID
column to your data and then use tidyr's pivot_wider()
.
suppressPackageStartupMessages({
library(tidyr)
library(dplyr)
})
dataLong<-tibble(CASEID=c(345,355,365,345,355,365),
CONDITION=c("ankylosis","chf", "arrhythmia","arrhythmia","HTN","diabetes"))
# Add ConditionId column
dataLong<-dataLong%>%mutate(ConditionID=rep(1:2,each=3))
# Pivot into wide format
dataLong%>%
pivot_wider(names_from = ConditionID,values_from=CONDITION,names_prefix="Condition")
#> # A tibble: 3 x 3
#> CASEID Condition1 Condition2
#> <dbl> <chr> <chr>
#> 1 345 ankylosis arrhythmia
#> 2 355 chf HTN
#> 3 365 arrhythmia diabetes
Created on 2020-12-28 by the reprex package (v0.3.0)