Skip to content
Prev 69950 / 398506 Next

from list to dataframe

I was wondering if someone can help me figure out the following:
I have two patient datasets, ds1 and ds2.  ds1 has fields "patid", "date", 
and "lab1".  ds2 has "patid", "date", and "lab2".  I want to find all the 
patids that have at least 2 dated records for each lab.  I started by 
splitting each dataset by patid, to create ds1.list and ds2.list.  Then I 
did some processing (with sapply) to each list to get the lengths of each 
patient list item.  Then I kind of lost my way and things got messy as I 
tried to extract just the patids of those with lengths >= 2, convert them 
to dataframes (which I didn't have much success with), and then merge the 
two dataframes to get a vector of the desired patids.  Any help would be 
much appreciated.

Thanks,
Steven