Dear R-users,  I have a problem, I have the following dataframe:
 
d<-data.frame(
 'y1'=c(1,2,1,2,1,NA,NA),
'y2'=c(1,2,1,1,1,2,1),
'y3'=c(1,NA,1,NA,NA,2,1),
'y4'=c(NA,2,NA,1,1,2,NA),
'a'=c(1,1,1,1,1,1,2)
)

where the last variable counts the number of missing values in a row. Now, i want to set rows where a>1 to NA and arrive at something like the following;
 
dnew<-data.frame(
 'y1'=c(1,2,1,2,1,NA,NA),
'y2'=c(1,2,1,1,1,2,NA),
'y3'=c(1,NA,1,NA,NA,2,NA),
'y4'=c(NA,2,NA,1,1,2,NA),
'a'=c(1,1,1,1,1,1,4)
)

Please, how do I go about this. Many thanks!
 
John  


      
	[[alternative HTML version deleted]]

