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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!