0

I was trying to splice a vector in R when I observed a very strange thing.

When I enter-

a <- c(1,2,3,4)
input <- 1
a[input + 1: length(a)]

The output is

[1]  2  3  4 NA

But when I enter-

a <- c(1,2,3,4)
input <- 1
a[(input + 1): length(a)]

The output is

[1]  2  3  4

Why is this strange behavior observed?

Vaibhav Sharma
  • 2,293
  • 1
  • 17
  • 24

0 Answers0