For questions like this, go to the manual.
Visit cran.r-project.org
The nav-bar on the left includes
"Documentation/Manuals/FAQ/Contributed". Click on Manuals.
Look at "An Introduction to R" and click on the HTML link for the
current release
(this is the first link on the page)
Scroll down to see
As with a lot of things in R, the behaviour is counterintuitive but
(arguably) logical. The key (maybe) is that `a[-x]` does not mean "take
all of the elements of a except those indicated by `x`, but rather,
"negate x, then take all but the negative elements". In other words,
-integer(0)
To the R-Help list,
I would like to have a clarification about an issue that I observe when
subsetting a vector. This is R version 4.3.3 on Windows 10.
-- Example with a vector:
> a <- 1:5
> a
[1] 1 2 3 4 5
So we have, with a negative index:
> a[-3]
[1] 1 2 4 5
But when the index is integ
3 matches
Mail list logo