I hereby protest strongly against the misuse of this thread through
unnecessary and pointless discussions. My request was satisfactorily
answered with references to R libraries and legitimate warnings about
the use of zero-based indexing schemes in R. If you want to continue
the discussions,
Note that elt(x, -1) is NOT AN OCCURRENCE OF AN EXISTING OPERATION.
It's a call to elt(-,-), which has its own semantics.
And the semantics of (x, i) when i is outside the interval
[0,length(x)) is UNDEFINED.
# elt(x, i) where i is numeric and all(0 <= i & i < length(x)) selects
one or more
#
No, my claim ISN'T false, In fact, it CANNOT be.
Here's my claim again, in slow speed.
1. The goal is to get the EFFECT of 0-origin indexing, Not
necessarily the syntax.
2. Rule A. NO NEW DATA TYPES.
3, Rule B. NO CHANGES TO EXISTING OPERATIONS, INCLUDING "[" and "[<-",
>From rules A and B, it
"This works with any single-index value, and lets all the existing
operations for such values continue to work."
As Peter Dalgaard already pointed out, that is false.
> x <- 1:4
> x[-1]
[1] 2 3 4
> elt(x,-0)
[1] 1
Cheers,
Bert
On Tue, Apr 23, 2024 at 4:55 PM Richard O'Keefe wrote:
>
> Does it
ide R. Many implementations only work with known cases and can break
> when combined, perhaps with other newer changes to R or packages. But, if
> used within a carefully designed environment they may do what you need and
> preserve functionality.
>
>
>
>
> -Original Message-
Does it have to use square bracket syntax?
elt <- function (x, i) x[i+1]
"elt<-" <- function (x, i, value) { x[i+1] <- value; x }
> u <- c("A","B","C")
> elt(u,0)
[1] "A"
> elt(u,length(u)-1)
[1] "C"
> elt(u,0) <- "Z"
> u
[1] "Z" "B" "C"
This works with any single-index value, and lets all the
, April 23, 2024 10:24 AM
To: Peter Dalgaard
Cc: R help project ; Hans W
Subject: Re: [R] x[0]: Can '0' be made an allowed index in R?
Hello Peter,
Unless I too misunderstand your point, negative indices for removal do
work with the Oarray package (though -0 doesn't work to remove the 0th
element
or (i in -29 to 120) { print(df[i+Offset])}
>>>
>>>
>>> 2) use absolute values if all indices are negative.
>>> for (i in -200 to -1) {print(df[abs(i)])}
>>>
>>> Tim
>>>
>>>
>>>
>>> -Original Mes
2) use absolute values if all indices are negative.
for (i in -200 to -1) {print(df[abs(i)])}
Tim
-Original Message-
From: R-help On Behalf Of Peter Dalgaard via
R-help
Sent: Monday, April 22, 2024 10:36 AM
To: Rolf Turner
Cc: R help project ; Hans W
Subject: Re: [R] x[0]: Can '0'
via
> R-help
> Sent: Monday, April 22, 2024 10:36 AM
> To: Rolf Turner
> Cc: R help project ; Hans W
> Subject: Re: [R] x[0]: Can '0' be made an allowed index in R?
>
> [External Email]
>
> Heh. Did anyone bring up negative indices yet?
>
> -pd
>
>> On
> Ben Bolker
> on Sun, 21 Apr 2024 10:23:50 -0400 writes:
> Also https://cran.r-project.org/package=Oarray (which is older and
> hence possibly more stable)
also maintained and written by a careful and really good person.
I do recommend Oarray as well.
Martin
BB> On
Subject: Re: [R] x[0]: Can '0' be made an allowed index in R?
[External Email]
Heh. Did anyone bring up negative indices yet?
-pd
On 22 Apr 2024, at 10:46 , Rolf Turner wrote:
See fortunes::fortune(36).
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
Universit
elp On Behalf Of Peter Dalgaard via
R-help
Sent: Monday, April 22, 2024 10:36 AM
To: Rolf Turner
Cc: R help project ; Hans W
Subject: Re: [R] x[0]: Can '0' be made an allowed index in R?
[External Email]
Heh. Did anyone bring up negative indices yet?
-pd
> On 22 Apr 2024, at 10:46 , Rolf
Heh. Did anyone bring up negative indices yet?
-pd
> On 22 Apr 2024, at 10:46 , Rolf Turner wrote:
>
>
> See fortunes::fortune(36).
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Stats. Dep't. (secretaries) phone:
>
Thanks for pointing out the 'Oarray' package which indeed for me works
slightly better than the 'index0' package.
library(Oarray)
x <- Oarray(data=c(2,3,5,7,11,13,17,19), offset=0)
x
#> [0,] [1,] [2,] [3,] [4,] [5,] [6,] [7,]
#>2357 11 13 17 19
Though
See fortunes::fortune(36).
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
+64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619
__
R-help@r-project.org
are
not?
Beware some solutions may be incomplete and may result in subtle errors.
Just routinely adding 1 seems safer as you know what you will get.
-Original Message-
From: R-help On Behalf Of Hans W
Sent: Sunday, April 21, 2024 3:56 AM
To: R help project
Subject: [R] x[0]: Can '0' be made an allowed
Also https://cran.r-project.org/package=Oarray (which is older and
hence possibly more stable)
On 2024-04-21 3:55 a.m., Hans W wrote:
As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
correct expression. Some algorithms, e.g. in graph theory or combinatorics,
are much
https://cran.r-project.org/package=index0
On Sun, Apr 21, 2024, 3:56 AM Hans W wrote:
> As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
> correct expression. Some algorithms, e.g. in graph theory or combinatorics,
> are much easier to formulate and code if 0 is an
Às 09:08 de 21/04/2024, Rui Barradas escreveu:
Às 08:55 de 21/04/2024, Hans W escreveu:
As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
correct expression. Some algorithms, e.g. in graph theory or
combinatorics,
are much easier to formulate and code if 0 is an allowed
Às 08:55 de 21/04/2024, Hans W escreveu:
As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
correct expression. Some algorithms, e.g. in graph theory or combinatorics,
are much easier to formulate and code if 0 is an allowed index pointing to
the first element of the
As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
correct expression. Some algorithms, e.g. in graph theory or combinatorics,
are much easier to formulate and code if 0 is an allowed index pointing to
the first element of the vector.
Some programming languages, for
22 matches
Mail list logo