Hi all,
 
I have a data set, named ‘data1.long’,
which has 180 subjects with two variables, ‘time’ and ‘patient’. The ‘time’
variable takes 9 values, i.e., 1, 2, 3,…,9, and the ‘patient’ variable takes
two values, 0 and 1. There are 10 subjects for each combination of ‘time’ and ‘patient’.
And there are no missing values for the two variables.
 
I then assign NAs to the ‘time’ variable
for 10 subjects by doing:
data1.long[data1.long$time==5 &
data1.long$patient==0, "time"] <- NA
 
Then I check the result using:
data1.long[data1.long$time==9,
"time"]
 
R returns 
[1]  9  9  9 NA NA  9 NA  9  9  9  9  9 NA  9  9 NA  9 NA  9  9 NA  9 NA  9
NA  9  9  9 NA  9
 
where I should’ve gotten 20 9’s. Another
checking is this:
data1.long[data1.long$time==9 &
data1.long$patient==0, "time"]
 
which should give me 10 9’s but instead, it
returns
[1]  9 NA NA  9 NA  9 NA  9
NA  9 NA  9  9 NA NA  9 NA  9  9 NA
 
Is there anything wrong with my assigning
of NA values?
 
Thank you for the help.
 
Chia-Chieh Lin
	[[alternative HTML version deleted]]

