我想用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)
.
.
.