I have a list L of data frames with two columns each…a key, and a value column. I would like to create a data frame where the i-th column is the value column for the i-th data frame. The problem is that different data frames in the list L have slightly different keys (the same for the most part but give or take a couple from data.frame to data.frame) so a simple do.call with a cbind won’t cut it). I looped over the list of data frames and took the union of the key columns to get an all encompassing set of keys bigKeySet…what I’d like to do now then is build this data.frame where there is a row for each of the keys in this bigKeySet, and an NA entry in a column if that data.frame did not have an entry for that key. I am not sure how to do this, however – any suggestions?
Share
Assuming you have a function
valueForKey()that returns a value for a key (or equivalent statement):You can bind
resultto your data frame of interest. Repeat for all instances ofmyKeys.