Question: Consider the following vector: v < - 1 : 1 0 Which of the following program is the correct way to calculate the running mean?

Consider the following vector:
v <-1:10
Which of the following program is the correct way to calculate the running mean? Heres the expected result:
[1]1.01.52.02.53.03.54.04.55.05.5
Group of answer choices
for (i in 1:length(v)) r3<- mean(v[1:i])
for (i in 1:length(v)) r4<- mean(v[i])
r1<- c()
for (i in 1:length(v)) r1<- c(r1, mean(v[1:i]))
for (i in 1:length(v)) r2<- c(r2, mean(v[1:i]))

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 Programming Questions!