I need to store the plane's elevation every period in a vector called 'position'.

the code below shows how the plane's elevation starts at 5 and with every iteration the

plane goes up or down by one unit. Eventually, the plane will hit elevation zero, at which point the loop should stop.

the object iterator is 'time' in the code.

My task is to store the plane's elevation every period in a vector called 'position'

Please help me with this question, thank you so much.

```
max_period <- 100
elevation <- 5
time <- 0
while(elevation > 0){
elevation <- elevation + sample(c(-1,1), 1)
time <- time + 1
print(paste("Current time:", time, " Elevation: ", elevation))
if (time > max_period && elevation > 0) {
break
}
}
if (elevation == 0) {
print(paste("CRASH! You lasted", time, "periods."))
} else {
print(paste("NOT CRASHED! You lasted", time, "periods.", "Elevation", elevation))
}
```