循环变量在R中的一个文件中写入和

时间:2015-06-08 10:43:57

标签: r

我想用R将两个值及其总和写入一个文件中。有没有办法让这个真正的循环?

write(c('P_1', 'P_1', sum(V[P_1, P_1])), file = 'P.tab', append = T, ncolumns = 3)
write(c('P_1', 'P_2', sum(V[P_1, P_2])), file = 'P.tab', append = T, ncolumns = 3)
write(c('P_1', 'P_3', sum(V[P_1, P_3])), file = 'P.tab', append = T, ncolumns = 3) 
write(c('P_1', 'P_4', sum(V[P_1, P_4])), file = 'P.tab', append = T, ncolumns = 3)
write(c('P_1', 'P_5', sum(V[P_1, P_5])), file = 'P.tab', append = T, ncolumns = 3)
.
.
.

0 个答案:

没有答案