dgkf / dgkf/R

Indexing with negative values is not supported yet

Open
#169 0 comments 0 reactions 0 assignees View on GitHub
meta-good first issue type-bug type-enhancement
Dominant language
Rust
Stars
145
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Just to document this, it is currently not possible to index vectors with negative values

```r
> x = 1:10
[1] 1 2 3 4 5 6 7 8 9 10
> x[-1]
double(0)
```

In `R`, it is possible to index with negative values to exclude them:

```r
> x = 1:10
> x[-1]
[1] 2 3 4 5 6 7 8 9 10
>
```

When implementing this feature it is important to pay attention to now allow mixing positive and negative indices, this even throws an error in R:

```r
> x[c(-1, 2)]
Error in x[c(-1, 2)] : only 0's may be mixed with negative subscripts
> x[c(-1, 0)]
[1] 2 3 4 5 6 7 8 9 10
>
```

I don't quite understand why indexing with `0` is allowed, but as we generally throw an error when using out-of bound indices this is nothing we should have to worry about.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.