I plotted the contents of csv file (which has either 0's or 1's as elements) in the following way
mat <- read.csv("trial.csv", header=T, row.names=1)
vec <- as.vector(as.matrix(mat))
varieties = names(mat)
matVar = matrix(vec, ncol = length(varieties), nrow = length(attr(mat, "row.names")))
library(ggplot2)
require(reshape2)
mat$id <- rownames(mat)
gg <- melt(mat)
ggplot(gg, aes(x=id,y=variable,fill=value))+
geom_tile()+
scale_fill_gradient(low="red",high="white")+
theme(axis.text.x = element_text(angle=90))+
coord_flip()
My data looks something like this, where I excluded row1 and column1. Now I'd like to get the sum of all 1's or 0's in each column and row and represent it at the end of the column and row respectively. I'd really appreciate any suggestions on how to do this.
h1, h2, h3, h4, h5, h6, h7, h8, h9
a, 1, 1, 1, 0, 1, 1, 0, 1
b, 0, 1, 1, 1, 0, 0, 0, 0
c, 1, 0, 0, 1, 1, 1, 1, 1
d, 1, 0, 1, 0, 0, 0, 1, 0
e, 1, 0, 0, 0, 0, 1, 0, 0
f, 1, 1, 0, 0, 0, 0, 0, 0
g, 0, 0, 0, 0, 0, 0, 0, 0
h, 0, 0, 0, 0, 0, 1, 1, 0