Re: R-alpha: Misc problems

Ross Ihaka (
Tue, 18 Feb 1997 08:41:49 +1300 (NZDT)

Date: Tue, 18 Feb 1997 08:41:49 +1300 (NZDT)
From: Ross Ihaka <>
Message-Id: <>
Subject: Re: R-alpha: Misc problems

Martin Maechler stands accused of saying:

> >>>>> "Jim" == Jim Lindsey <> writes:

>     Jim> 1. The S books often give examples using something like this:
>     Jim>   u <- list()
>     Jim>   u[[1]] <- a

>     Jim> In R this gives subscript out of bounds (also character, vector, etc.)

> I think that R is okay here;
> Why using unnamed lists anyway?
> In the above example, you can do

> 	u $  <-  a

> A similar issue (which was discussed on this list a while ago):

> 	x    <- 1:4
> 	x[6] <- 6

> works in S, but not in R.
> The decision was that R should help you to detect programming errors.

Yes this was the rationale,  but we also took a board decision to be as
compatible as possible with S (the year before last no?).

In the interests of compatibility I have already added code which
provides "stretchy" vectors and lists for the next version.  There is a
lot of code which uses this facility.  I have been checking our object
system code by running Bill Venables "polynomial" class code and it
uses this facility.

I might point out that this tends to be very inefficient, on a par
	x <- NULL
	for(i in 1:10) x <- c(x, i)

which is better written as
	x <- numeric(10)
	for(i in 1:10) x[i] <- i

You might also want to amuse yourself by trying the following code in S:
	x <- matrix(1:10, nc=2)
	x[20] <- 17
	# Hunh? where did the extra values go?
	# Oh! there they are

r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: