Question: in R Write a function called `calculateRowMeans` that uses a **for loop** to calculate the row means of a matrix `x`. Im sure that I
in R
Write a function called `calculateRowMeans` that uses a **for loop** to calculate the row means of a matrix `x`.
Im sure that I wrote the wrong chunk:
```{r} fake.data1<-matrix(rnorm(500),ncol=5) calculateRowMeans<-numeric(nrow(fake.data)) for(i in 1:nrow(fake.data)){ calculateRowMeans<-mean(i[i,]) } calculateRowMeans ```
could you please explain to me that how to make it correct?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
