Creates a long dataset of "n" columns comprising the combinations of values from different columns.
lengthener(indt, n = 2)
indt | The input dataset. |
---|---|
n | The number of columns expected. Passed on to |
A data.table
.
http://stackoverflow.com/q/35690478/1270695
Ananda Mahto
#> V1 V2 #> 1: 1 2 #> 2: 1 3 #> 3: 1 4 #> 4: 2 3 #> 5: 2 4 #> 6: 3 4 #> 7: 0 0 #> 8: 0 1 #> 9: 0 1 #> 10: 0 1 #> 11: 0 1 #> 12: 1 1lengthener(mydf, 3)#> V1 V2 V3 #> 1: 1 2 3 #> 2: 1 2 4 #> 3: 1 3 4 #> 4: 2 3 4 #> 5: 0 0 1 #> 6: 0 0 1 #> 7: 0 1 1 #> 8: 0 1 1