'Modifying a For Loop in R to Work with Spreadsheet

I have a for loop that adds up every value in a spreadsheet along rows and prints the totals. I need to modify it to add up columns instead, find the average value among each column, and print the label for the column. Here's the for loop I have:

for(i in 1:14){
 sumALL [i] = sum(basalts[i,-1])
 print(sumALL [i])

}

Here is the spreadsheet

img

r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source