Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-24 Thread Hans W
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,

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-24 Thread Richard O'Keefe
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 #

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-24 Thread Richard O'Keefe
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Bert Gunter
"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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Richard O'Keefe
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-

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Richard O'Keefe
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread avi.e.gross
, 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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Jeff Newmiller via R-help
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread John Fox
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'

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Peter Dalgaard via R-help
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Martin Maechler
> 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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Spencer Graves
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Ebert,Timothy Aaron
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Peter Dalgaard via R-help
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: >

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Hans W
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Rolf Turner
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread avi.e.gross
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Ben Bolker
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Ben Bolker
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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Rui Barradas
À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

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Rui Barradas
À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

[R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Hans W
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