0

I have a data set consisting of repeated measures(4 waves), one data point per row. These data are from a longitudinal study, and measured two different tools based on the study subjects age; therefore, at the moment, not every ID has assessed using one measuring tool at wave one. In the data subject 1,4,7 has four repeated measures BITSEA at wave 1 and 2,3 and 4 CBCL subject 5 & 7 have four repeated measures CBCL at all waves

I want to be able to extract data points involved in all repeated measures. I wish to obtain those with four repeated measures using BITSEA if subjects are between 9 and 35 months else CBCL at wave 1. The background of my question is to create a data frame for those who have measured in all waves subsetting subjects measured at wave 1 using either BITSEA or CBCL. Any thoughts, please? the data looks like

dat <- read.table(structure(list(subject_id = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L,6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 9L, 10L, 10L, 10L, 10L), wave = c("wave1", "wave2", "wave3", "wave4", "wave1", "wave2", "wave3", "wave1", "wave2", "wave1","wave2", "wave3", "wave4", "wave1", "wave2", "wave3", "wave4","wave1", "wave2", "wave1", "wave2", "wave3", "wave4", "wave1", "wave2", "wave3", "wave1", "wave1", "wave2", "wave3", "wave4"), AgeinMonths = c(10L, 38L, 56L, 76L, 38L, 46L, 66L, 23L, 41L,35L, 56L, 76L, 98L, 36L,54L, 74L, 92L, 38L, 58L, 11L, 36L, 49L, 69L, 17L, 37L, 55L, 36L, 36L, 54L, 72L, 90L), BITSEA = c("7","Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "27", "Not applicable", "28", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable","Not applicable", "23", "Not applicable", "Not applicable", "Not applicable", 
         "26", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable", "Not applicable"),                                CBCL = c(NA, "66", "73", "87", "57", "63", "77", NA, "38", NA, "70", "77",  "97", "66", "45", "67", "68", "54", "63","Not applicable", "45",  "51", "65", "Not applicable", "45", "57", "56", "45", "55", "65,  "71"))
  • Aside: `dput` output does not need `read.table`. Please show desired result and your code attempt at solution. – Parfait Jun 11 '20 at 02:56
  • Your `dat`doesn't scan - there's at least 1 unclosed doublequote. Please edit your post to make a Minimal Reproducible Example. See https://stackoverflow.com/questions/5963269 . – David T Jun 11 '20 at 02:59

0 Answers0