我在重塑一个大型数据框时遇到了困难。以往我相对幸运地避免了这类问题,但也意味着我在此方面表现非常不好。
我当前的数据框大致如下:
unique_id seq response detailed.name treatment
a N1 123.23 descr. of N1 T1
a N2 231.12 descr. of N2 T1
a N3 231.23 descr. of N3 T1
...
b N1 343.23 descr. of N1 T2
b N2 281.13 descr. of N2 T2
b N3 901.23 descr. of N3 T2
...
And I'd like:
seq detailed.name T1 T2
N1 descr. of N1 123.23 343.23
N2 descr. of N2 231.12 281.13
N3 descr. of N3 231.23 901.23
我已经研究了reshape包,但是我不确定如何将治疗因素转换为单独的列名。
谢谢!
编辑:我在我的本地机器上尝试运行此操作(4GB双核iMac 3.06Ghz),但一直失败:
> d.tmp.2 <- cast(d.tmp, `SEQ_ID` + `GENE_INFO` ~ treatments)
Aggregation requires fun.aggregate: length used as default
R(5751) malloc: *** mmap(size=647168) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
我有机会的时候会试着在我们更大的机器上运行这个程序。