Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

How to update ccdata package

Sinan Shi edited this page May 4, 2016 · 3 revisions

Update ccRecord data structure

ccdata package is currently under development, therefore both data structure and definitions may be changed from time to time. Once the definition is changed, the parsed ccdata format in previous version is no longer valid. To solve this problem, we have to first extract raw data from previous ccRecord and using these raw data to construct a new ccRecord object.

  • Extract raw data using the following function under the old version
load('data_all_patients.Rdata')
ls()
> "ccd"
# extract data function
extractDataList <- function(record) {
    el <- lapply(record@patients, 
                 function(x) lapply(x@episodes, 
                                    function(e) {
                                        lapply(e@data, function(d) d)
                                    }))
    return(el)
}

# extract raw data. Since raw data can be applied to any future version (hopefully), 
# saving raw_data object on disc can avoid above operations in next update. 
raw_data <- extractDataList(ccd) 

# for later version one can use for_each_episode function alternatively
raw_data <- for_each_episode(ccd, function(x) x@data)
  • install new ccdata package and construct the new ccRecord object
new_ccd <- ccRecord() + raw_data