4
我通过将函数应用于data.table的某些子集来生成输出。我使用的功能是这样的:将矢量输出转换为data.table中的列?
data[, foo(args), by=list(Year, Month)]
我的功能foo
回报总是长度n
的载体。我得到的输出是这样的:
Year Month V1
1: 1983 2 9.734669e-06
2: 1983 2 9.165665e-06
3: 1983 2 2.097477e-05
4: 1983 2 3.803727e-05
不过,我想是这样
Year Month V1 V2 V3 V4 ...
1: 1983 2 9.734669e-06 9.165665e-06 2.097477e-05 3.803727e-05 ...
我甚至使用list(foo(args))
尝试,它并没有帮助。或者应该输出形式foo$V1, foo$V2 ...
?