HI all, I have some data to be screened based on the recording flag (obs). Some family recorded properly (1) and others not (0). Th 0 = improper and 1 = proper
The recording period starts week1. All families may not start in the same week in recording properly an observation, DF2 <- read.table(header=TRUE, text='family time obs A WEEK1 0 A WEEK1 0 A WEEK1 0 A WEEK2 1 A WEEK2 0 A WEEK3 1 A WEEK3 0 B WEEK1 1 B WEEK1 0 B WEEK1 1 B WEEK2 0 B WEEK2 0 B WEEK3 1 B WEEK3 0 C WEEK3 0 C WEEK3 0 C WEEK4 1 C WEEK4 1') Example, in week1 all records of family "A" are 0 (improper), but starting the week2 they start recording proper (1) records as well. Then I create a table that shows me the ratio of proper records to the total records for each family within week. If the ratio is zero and there is no prior proper recordings for that family then I want to delete those records. However, once any family started showing proper records as "1" and even if in the the subsequent week the ratio is 0 then I want keep that record for that family. Example records of week2 for family B Here is the summary table WEEK1 WEEK2 WEEK3 WEEK4 A 0 0.5 0.5 . B 0.33 0 0.5 . C . . 0 1 >From the above table For A- I want exclude all records of week1 and keep the rest. Because they were not recording it propeller For B- Keep all records, as they stated recording properly from the beginning. For C- Keep only the week4 records because all records are 1's Final and desired result will be A WEEK2 1 A WEEK2 0 A WEEK3 1 A WEEK3 0 B WEEK1 1 B WEEK1 0 B WEEK1 1 B WEEK2 0 B WEEK2 0 B WEEK3 1 B WEEK3 0 C WEEK4 1 C WEEK4 1 and the summary table looks like as follows WEEK1 WEEK2 WEEK3 WEEK4 A . 0.5 0.5 . B 0.33 0 0.5 . C . . . 1 Thank you in advance ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.