I'm relatively new to R and got stuck with an actually simple thing. I have panel data and I want to plot or count how many observation units experience a change in a specific variable over time. The data looks the following way:
statename,from,to,id,x
United States,1946,1965,201000,
United States,1946,1965,202000,
United States,1946,1965,203000,false
United States,1970,1973,203000,true
United States,1946,1965,204000,
United States,1946,1965,205000,true
So, to be precise, I want to get a number of how many ids experienced a change in x and/or how many always had true for x and how many always had false for x.
I tried to make a dummy that equals 1 if x was true at least once and false at least once, i.e., if there was a change. However, it did not work. I also tried to approach the problem with the table(), aggregate(), group_by() and count() functions (partly combined) but I just do not get what I want.
Can anybody possibly help?