One of the functions allowing to combine tables and lists in LibreOffice is Vlookup
- vertical lookup. What it does is to take a value, like the number 6 in your list, search in the first column of the table and return one of the values from the corresponding rows in the table.
Thus Vlookup
definition includes:
- the text or value to search for (single value)
- the range of cells (table) where to search that value - the function only looks into the first column of that range
- the number of the column desired as a result
- a logical value that defines if the original table is sorted (best left to 0)
The range of cells containing the table should be defined through absolute references (using the "$" sign in front of the cell references). As an example, I have used the same formula on columns F, G and H, but changed the recovered column number:
R gives a lot more flexibility and speed for the same operations but on short lists and with the data at hand Vlookup is pretty powerful. In R, merge.data.frame
is one of the functions that can be used for combining tables (data frames) by using a given column. If the table is in a data frame called tb
and the list is another data frame called ids
, merging the two would be done by:
>merged <- merge.data.frame(ids, tb, by.x="id", by.y="Id", sort=F)
> merged
id Name Age Affiliate
1 2 Y 33 DD
2 3 G 46 SS
3 5 W 80 CE
The names of the columns used to merge the tables are "id" and "Id".