ShanZhengYang - 1 month ago 6x

R Question

Let's say I have a

`data.table`

`> library("data.table")`

> DT = data.table(x=c("b","b","b","a","a","a"),v=rnorm(6))

> DT

x v

1: b 0.77399102

2: b 0.71450334

3: b 0.07187842

4: a -0.88098815

5: a -0.90192891

6: a 0.66439642

I supply a vector for the

`x`

`v`

However, you see that I supply

`b`

`a`

`'b' : '0.77399102', '0.71450334', '0.07187842'`

'a' : '-0.88098815', '-0.90192891', '0.66439642'

In R, one would implement this as a list, i.e.

`pairs = list(b = c('0.77399102', '0.71450334', '0.07187842'),`

a = c('-0.88098815', '-0.90192891', '0.66439642'))

I would like to input the R list

`pairs`

`data.table`

`x`

`v`

If this isn't possible, how would one do this?

Source (Stackoverflow)

Comments