Monday 15 July 2013

lookup tables - Mapping multiple IDs using R -


The idea is as follows: Every patient has a unique patient ID, which we call hidenic_id Although this patient can be admitted to the hospital several times. On the other hand, every entry has unique emtek_id

Patient 110380 4/14/2001 11:08 was admitted to the hospital and was then transferred through the hospital and 4/24/2001 18:16 was discharged. Now this patient has been admitted again on 5/11/2001 23:24 because he now has separate emtek_id. She has been discharged from the hospital on 5/25/2001 16:26. So you need to assign the correct emtek_ids by checking the dates if the date given in the composite file is within the entry and discharge time period (or very close to 24 hours), then we can specify that emtek_id.

How can I assign separate emtek_IDs to entries with hidenic_id and entry time?

I was intrested in your problem so I created some fake data and this problem Tried to solve but I escaped myself in some confusions and then posted my question, which I think is what you are asking, but more general. You can see the reaction here:

generates my post, what do I believe is the one you are starting from, and the answer checked is that what I believe you find Are there. The complete code is below, you will need to install zoo and IRanges . Also, I did it in version 2.15.3. Not installed properly in IRanges 3.0.0

  ## package installation source ( "http://bioconductor.org/biocLite.R") Bayoklait ( "Irnges") install.packages ( "Zoo") ## emtek and hidenic file Data library (zoo) date_string & lt; - Paste ("2001", sample (12, 10, 3), sample (28,10) generated Sep = "-") time_string & lt; - c ("23:03:20", "22: 26:56", "01:03:30", "18:21:03", "16:56:26", "23:03:20" , "22:29:56", "01:03:30", "18:21:03", "16:56:26") entry_metex & lt; - Striptaim (paste (Att_metek [Order (Antrymatak)] exit_emtek & lt; - entry_emtek + 3600 * 24 emtek_file & lt; - according to data entry & lt; - Entry _metek [date_string, time_string], "% y-% m -% d% H:% M:% S "frame (emtek_id = 1:10, entry_emtek, exit_emtek) hidenic_id & lt; - 110380: 110479 date_string & lt; - paste (" 2001 ", the sample (12, 100, location = TRUE), sample (28,100, substituted = T), sep = "-") time_string & lt; - delegate (C ("23:03:20", "22: 26:56", "01:03:30 "," 18:21:03 "," 16:56: 26 "," 23:03:20 "," 22:29:56 "," 01:03:30 "," 18:21:03 ", "16:56:26"), 10) hidenic_time & lt; - striptime (paste (dest_string, time_string), "% Y-% m-% d % H:% M:% S ") hidenic_time [order (hidenic_time)] hidenic_file & lt; - data.frame (hidenic_id, Hidenic_time) ## Find the intersection of AMTech and Hydenic Times. was: Agstadi Library (Airngs) ## to create a time lag about & lt; - Airnges (eg. numeric (emtek_file $ entry_emtek), as.numeric (emtek_file $ exit_emtek)) ## to create a time interval (start = End here) query & lt; - IRanges (as.numeric (hidenic_file $ hidenic_time), as.numeric (hidenic_file $ hidenic_time)) ## overlap and remove rows (both time points and intervals) emt.ids & lt; - theme style () search ovallap (query, subject) hid.ids & lt; - queryHits (Khojovrlap (query subject)) cbind (hidenic_file [hid.ids,], emtek_file [emt.ids,])    

No comments:

Post a Comment