I have the following example set of data:
Example<-data.frame(A=10*1:9,B=10*10:18)
rownames(Example)<-paste("Sample",1:9)
> Example
A B
Sample 1 10 100
Sample 2 20 110
Sample 3 30 120
Sample 4 40 130
Sample 5 50 140
Sample 6 60 150
Sample 7 70 160
Sample 8 80 170
Sample 9 90 180
I am trying to divide each element in both columns by its column's total. I have tried a variety of methods, but I feel like I am missing a fundamental piece of code that would make this easier. I have gotten this far:
ExampleSum1 <- sum(Example[,1])
ExampleSum2 <- sum(Example[,2])
But I don't know how to divide 10, 20, 30, etc by ExampleSum1
, etc.