df <- data.frame(x = rnorm(n=40), y = rnorm(n=40))
df <- df[do.call(order,df),]
(df <- transform(df,
x.2=cases(x>0,x<=0),
y.2=cases(y>0,y<=0),
z1=cases(
"Condition 1"=x<0,
"Condition 2"=(x>=0 & y <0),
"Condition 3"=TRUE
),
z2=cases(x<0,(x>=0 & y <0), (x>=0 & y >=0))
))
xtabs(~x.2+y.2,data=df)
Run the code above in your browser using DataLab