I wrote a function in R using the code below: when I run it, an error message occurs: How does this happen?
columnmeans <- funtion(y) {
nc <- ncol[y]
means <- numeric(nc)
for (i in 1:nc) {
mean[i] <- mean(y[,i])
}
mean
}
I expect the function to work, but instead I received:
Error: unexpected '}' in "}"