I have a data frame DF:
DF=data.frame(index=1:6,pos=I(list(c(21, 22, 24),c(21, 24),c(21, 22, 23, 24), 26, c(1, 21),c(14, 21, 23))))
the data structure:
str(DF)
'data.frame': 6 obs. of 2 variables:
$ index: int 1 2 3 4 5 6
$ pos :List of 6
..$ : int 21 22 24
..$ : int 21 24
..$ : int 21 22 23 24
..$ : int 26
..$ : int 1 21
..$ : int 14 21 23
I would like to generate a column to hold unique elements by combining the first row with the following rows, and still as a list. So the expected result is:
index pos result
1 21, 22, 24 21, 22, 24
2 21, 24 21, 22, 24
3 21, 22, 23, 24 21, 22, 23, 24
4 26 21, 22, 24, 26
5 1, 21 1, 21, 22, 24
6 14, 21, 23 14, 21, 22, 23, 24
The first row in "result" column is the same as "pos", the second row is the list of unique elements by combining the first row and the second row of "pos" column, ... I expect the mode and class of column "result" is the same as "pos". Appreciate any helps for this.