We’ve seen in the previous exercise that not all subjects can enter the elevator, since the sum of their weights (saved in the vector weights.kg.all
) exceeds 630 kg.
To decide who can enter the elevator: calculate
the cumulative weights using the function cumsum() and store them in a vector (with a length of 10)
called cum.weight
.
If you print the vector cum.weight
in your RStudio environment: it should look like:
[1] 59.8752 144.6984 244.4904 319.3344 370.5912 439.5384 530.2584 591.0408 672.6888 767.9448
.