I wanted to calculate the standard deviation for each column in my data set below:
a b c
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
I tried creating a loop like this:
for (x in 1:3){
sdcol=sd(data[,x])
}
But I get the following error:
Error in data[, x] : object of type 'closure' is not subsettable
Can you help me with such a loop?
Thanks