Reputation: 437
I created a simple vector in R to store the temperatures of 3 patients.
temperature <- c(98.1, 98.6, 101.4)
then later I tried to retrieve the temperature of the second and third patient.
temperature[2:3] [1] 98.6 101.4
While trying to retrieve all three values I succeeded but then got this warning from RStudio
temperature[1:2:3] [1] 98.1 98.6 101.4
Warning message: In 1:2:3 : numerical expression has 2 elements: only the first used
What does this warning mean?
Upvotes: 0
Views: 71
Reputation: 4816
The expression temperature[1:2:3]
though is valid (valid in the sense that it will compile without errors) in R, but will give you same result as temperature[1:3]
.
R only uses the first and the last indices. So, temperature[1:3:4:5:3]
is same as temperature[1:3]
.
Upvotes: 2