I have the data iris and I want to make the data iris - mean of each column in data iris so i have code like this
y=iris[,1:4]
t=y-colMeans(y)
t
so the column show the matrix data iris - means of column. So I want to ask about how to create like that but with looping I write like this
for(i in 1:4){y[,i]=iris[,i]-colMeans(iris[,i])}
but the result problem that 'x' must be an array of at least two dimensions
Please help me fix this
With
dplyr
we can doOr using
lapply