1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| table = read.csv('D:/essai_rca.csv', header = TRUE, sep = ";")
table1 = as.data.frame(matrix( table$Mcp, ncol = length(unique(table$Reporter.ISO)) ,
nrow = nrow(table)/length(unique(table$Reporter.ISO))))
colnames(table1) = unique(table$Reporter.ISO)
row.names(table1)= unique(table$Commodity.Code)
table1 = cbind(table1, rowSums(table1))
table1 = rbind(table1, colSums(table1))
colnames(table1) = c(colnames(table1)[1:(ncol(table1)-1)], 'total')
row.names(table1)= c(row.names(table1)[1:(nrow(table1)-1)],'total')
table1
# TN DZA FR total
# 1 1 1 0 2
# 2 0 1 1 2
# 3 0 0 1 1
# 4 1 1 0 2
# total 2 3 2 7 |
Partager