2016-03-06 85 views
1

假設我有一個data.tablex[R骨料由兩個因素

x <- data.table(Motif = c("A","A","B","B","B","C"), 
       Strain = c(1,1,1,2,2,3), 
       IPDRatio = c(1:6)) 

我怎麼會找到IPDRatio柱倒塌的因素,整個data.tableMotifStrain什麼意思呢?

所需的輸出:

Motif Strain IPDRatio 
1:  A  1  1.5 
2:  B  1  3 
3:  B  2  4.5 
4:  C  3  6 

回答

2

這應該工作

x[, mean(IPDRatio), list(Motif, Strain)]