[R] simple data.frame question

Troels Ring tring at gvdnet.dk
Wed May 16 17:56:04 CEST 2012


Dear friends - I hope you will forgive me another simple question, 
illustrated by

ID <- c(1,1,1,2,2,3,3,3)
PERIOD <- c(1,2,3,2,3,1,2,3)
X <- runif(8,0,10))

FF <- data.frame(ID=ID,PERIOD=PERIOD,X=X)

I need to the fourth value of X as NA, and ID and PERIOD is updated to 
1,1,1,2,2,2,3,3,3 and 1,2,3,1,2,3,1,2,3 respectively.
How do I use the pattern in ID and PERIOD to find the lacking X and put NA?

Best wishes

Troels Ring,
Aalborg, Denmark



More information about the R-help mailing list