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, PLEASE open another thread for it as I receive all
these comments as unsolicited emails.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
# elements from x using 0-origin elements.  i should not be logical and must not
# be character.  This cannot be used for deleting.
elt <- function (x, i) x[i+1]

# elt(x, i) <- value where i is numeric and all(0 <= i & i <
length(x)) replaces one
# or more elements of x with (corresponding elements of) value using
0-origin indexing.
# i should not be logical and must not be character.
"elt<-" <- function (x, i, value) { x[i+1] <- value; x}

The goal was to get the effect of 0-origin indexing, and that's all
elt(-,-) is defined to do.
Recall the starting point of this thread.
There is existing code in another language or other languages where
0-origin is the
norm, and it would be pleasant to transliterate it into R introducing
fewer errors.
That language/those languages almost certainly do not use R's negative-indexing-
for-deletion.  Even APL doesn't do that.  Therefore elt(-,-) need not
do that.  And it
doesn't,

And a limitation like this is useful.  If you want to change/extend
the semantics of :"[",
you have to worry about ALL the legal ways to use "[".
But if you are introducing a NEW operation you only have to worry
about the things
it's intended to do (like play the limited role that indexing plays in
some other language(s)).

On Wed, 24 Apr 2024 at 13:20, Bert Gunter  wrote:
>
> "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 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 existing
> > operations for such values continue to work.  It seems to me to be the
> > simplest and cleanest way to do things, and has the advantage of
> > highlighting to a human reader that this is NOT normal R indexing.
> >
> > On Sun, 21 Apr 2024 at 19:56, 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 allowed index pointing to
> > > the first element of the vector.
> > >
> > > Some programming languages, for instance Julia (where the index for normal
> > > vectors also starts with 1), provide libraries/packages that allow the 
> > > user
> > > to define an index range for its vectors, say 0:9 or 10:20 or even 
> > > negative
> > > indices.
> > >
> > > Of course, this notation would only be feasible for certain specially
> > > defined vectors. Is there a library that provides this functionality?
> > > Or is there a simple trick to do this in R? The expression 'x[0]' must
> > > be possible, does this mean the syntax of R has to be twisted somehow?
> > >
> > > Thanks, Hans W.
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 follows that EXISTING OPERATIONS (which aren't changed)
continue to work on EXISTING DATA TYPES (which aren't changed) because
NOTHING RELEVANT CHANGES.
4. Rule C.  As a consequence of rules A and B, to accomplish the goal we should
DEFINE A NEW OPERATION with a new name that does whatever we want it to.
5. Because existing code does not call the new operation (it's a new name),
it does not break.  (OK, if something depends on the absence of "elt",
that could
break.  But code that depends on the absence of variables is broken already.)
6. The specific proposal was
elt <- function (x, i) x[i+1]
"elt<-" <- function (x, i, value) { x[i+1] <- value; x }
7, with the implication that you can use any name you like
8. and the perhaps less obvious implication that these definitions can
be local to
a function or a namespace.

The idea is that instead of foobar[0] with a modified data type for foobar or a
modified definition for "[" you write elt(foobar, 0) which obviously
isn't a normal
use of "[".

If you can explain how this breaks normal indexing, pray do so.

On Wed, 24 Apr 2024 at 13:20, Bert Gunter  wrote:
>
> "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 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 existing
> > operations for such values continue to work.  It seems to me to be the
> > simplest and cleanest way to do things, and has the advantage of
> > highlighting to a human reader that this is NOT normal R indexing.
> >
> > On Sun, 21 Apr 2024 at 19:56, 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 allowed index pointing to
> > > the first element of the vector.
> > >
> > > Some programming languages, for instance Julia (where the index for normal
> > > vectors also starts with 1), provide libraries/packages that allow the 
> > > user
> > > to define an index range for its vectors, say 0:9 or 10:20 or even 
> > > negative
> > > indices.
> > >
> > > Of course, this notation would only be feasible for certain specially
> > > defined vectors. Is there a library that provides this functionality?
> > > Or is there a simple trick to do this in R? The expression 'x[0]' must
> > > be possible, does this mean the syntax of R has to be twisted somehow?
> > >
> > > Thanks, Hans W.
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [Rd] R 4.4.0 is released

2024-04-24 Thread Peter Dalgaard via R-announce
The build system rolled up R-4.4.0.tar.gz and R-4.4.0.tar.xz (codename "Puppy 
Cup") this morning.

This is a major update, containing many new features and bug fixes.

The list below details the changes in this release. 

You can get the source code from

https://cran.r-project.org/src/base/R-4/R-4.4.0.tar.gz
https://cran.r-project.org/src/base/R-4/R-4.4.0.tar.xz

or wait for it to be mirrored at a CRAN site nearer to you.

Binaries for various platforms will appear in due course.


For the R Core Team,

Peter Dalgaard


These are the checksums (md5 and SHA-256) for the freshly created files, in 
case you wish
to check that they are uncorrupted:

MD5 (AUTHORS) = 7af154b485d63c810210f8093c300dc6
MD5 (COPYING) = eb723b61539feef013de476e68b5c50a
MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343
MD5 (FAQ) = 8c980fe8c8bd9fe872fd9cd9774e5c9e
MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b
MD5 (NEWS) = 1eeb7eec5f4d1c1121a433938b1515a5
MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8
MD5 (NEWS.1) = f8466e418dec6b958b4ce484a13f9a9d
MD5 (NEWS.2) = b38d94569700664205a76a7de836ba83
MD5 (NEWS.3) = 307e75ba323c08b8694f916e45886aa4
MD5 (R-latest.tar.gz) = 400b43da0c2e67e62ec9f90d509a9e10
MD5 (R-latest.tar.xz) = 647ef3e012e9cf36a187db64a6082217
MD5 (README) = f468f281c919665e276a1b691decbbe6
MD5 (RESOURCES) = a79b9b338cab09bd665f6b62ac6f455b
MD5 (THANKS) = 45b6d2e88a6ecb5b24fa33a781351cd5
MD5 (VERSION-INFO.dcf) = 0d8b5abfa71e0a6b6d934ce28dfc81b8
MD5 (R-4/R-4.4.0.tar.gz) = 400b43da0c2e67e62ec9f90d509a9e10
MD5 (R-4/R-4.4.0.tar.xz) = 647ef3e012e9cf36a187db64a6082217


f00177d1ba0a6fdf85a87ef2bb20a39edbc7108dec2852042c2b5a00783b2df5  AUTHORS
e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4  COPYING
6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3  COPYING.LIB
64eecb635b7c2d511d58ace067825dfc5174bf2225b0935d880ca869b037c7e1  FAQ
f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31  INSTALL
d17ac7c22d5411b47597fa84cd887e75c6976b38ad0cdfd2fd37e4333a7f19b4  NEWS
4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62  NEWS.0
602f3a40ef759c7b2a6c485a33dc674af34249644ac5fb53b21283d4e12e808d  NEWS.1
cde079b6beab7d700d3d4ecda494e2681ad3b7f8fab13b68be090f949393ec62  NEWS.2
05f3f9fc664b845bb3dcc6492503860df72c63b3f179ab241c095e25bb7628f9  NEWS.3
ace4125f9b976d2c53bcc5fca30c75e30d4edc401584859cbadb080e72b5f030  
R-latest.tar.gz
5c6c4c2df763fcdd985c5696e909e13c80d75d5f80d42c1adb72fabef4b23d57  
R-latest.tar.xz
2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc  README
8b7d3856100220f4555d4d57140829f2e81c27eccec5b441f5dce616e9ec9061  RESOURCES
8319c5415de58ee10d4bc058d79c370fd8e6b2ad09e25d7a1e04b74ca5f380a6  THANKS
9ec1217b980300e2f422548703811f12cc0cdd40d152050cf78e4ffb63c85f76  
VERSION-INFO.dcf
ace4125f9b976d2c53bcc5fca30c75e30d4edc401584859cbadb080e72b5f030  
R-4/R-4.4.0.tar.gz
5c6c4c2df763fcdd985c5696e909e13c80d75d5f80d42c1adb72fabef4b23d57  
R-4/R-4.4.0.tar.xz

This is the relevant part of the NEWS file

CHANGES IN R 4.4.0:

  SIGNIFICANT USER-VISIBLE CHANGES:

* Startup banners, R --version, sessionInfo() and R CMD check no
  longer report (64-bit) as part of the platform as this is almost
  universal - the increasingly rare 32-bit platforms will still
  report (32-bit).

  On Windows, ditto for window titles.

* is.atomic(NULL) now returns FALSE, as NULL is not an atomic
  vector.  Strict back-compatibility would replace is.atomic(foo)
  by (is.null(foo) || is.atomic(foo)) but should happen only
  sparingly.

  NEW FEATURES:

* The confint() methods for "glm" and "nls" objects have been
  copied to the stats package.  Previously, they were stubs which
  called versions in package MASS. The MASS namespace is no longer
  loaded if you invoke (say) confint(glmfit).  Further, the "glm"
  method for profile() and the plot() and pairs() methods for class
  "profile" have been copied from MASS to stats.  (profile.nls()
  and plot.profile.nls() were already in stats.)

* The confint() and profile methods for "glm" objects have gained a
  possibility to do profiling based on the Rao Score statistic in
  addition to the default Likelihood Ratio. This is controlled by a
  new test = argument.

* The pairs() method for "profile" objects has been extended with a
  which = argument to allow plotting only a subset of the
  parameters.

* The "glm" method for anova() computes test statistics and
  p-values by default, using a chi-squared test or an F test
  depending on whether the dispersion is fixed or free.  Test
  statistics can be suppressed by giving argument test a false
  logical value.

* In setRepositories() the repositories can be set using their
  names via name = instead of index ind =.

* methods() and .S3methods() gain a all.names option for the (rare)
  case where functions starting with a . should be included.

* Serializations ca