Say I have a data frame with the contents:
Trial Person
1 John
2 John
3 John
4 John
1 Bill
2 Bill
3 Bill
4 Bill
and I want to transform this to
Trial Person Day
1 John 1
2 John 1
3 John 2
4 John 2
1 Bill 1
2 Bill 1
3 Bill 2
4 Bill 2
I can very easily make it
Trial Person Day
1 John TRUE
2 John TRUE
3 John FALSE
4 John FALSE
1 Bill TRUE
2 Bill TRUE
3 Bill FALSE
4 Bill FALSE
by doing d$day=d$trial<3
but how can I get to what I want?