Re: [R] Change in how R handles assignments?

About this list Date view Thread view Subject view Author view Attachment view

From: Prof Brian Ripley (
Date: Tue 18 May 2004 - 05:54:58 EST

Message-id: <Pine.LNX.4.44.0405172050220.12003-100000@gannet.stats>

On Mon, 17 May 2004, David Kreil wrote:

> Dear Prof Brian Ripley,
> Thank you very much for your fast and helpful answer!
> > > I have been using the following code in earlier versions of R:
> >
> > What `earlier versions'? As far as I know this was changed in 1.8.0.
> Yes, that fits my observations. We have an old 1.7.1-beta installation
> and a newer 1.8.1; the "old" code runs on the 1.7.1 but not on the
> 1.8.1.

1.9.0 is current, and R-patched (will become 1.9.1 is a few weeks) is
already available with this patched. 1.8.1 is `an earlier version'

> > > q[,names(info)]<-info[no,];
> > You do not need to terminate lines in ;, BTW.
> Thanks! A "bad" C-habit, I suppose.
> > But that was not what was documented. The intention is that the rhs be a
> > list, not a data frame.
> Ah! Is
> q[,names(info)]<-c(info[no,]);
> a good way of writing it then? It seems to work.
> > You can do
> > x[, names(info)] <- unclass(info[1, ])
> Great, thanks! Is there any advantage of using unclass() vs c()?

c() works only for a single row and columns of the same type. unclass
always works, as a list is the specified value in the docs.

> > We'll unclass a data frame rhs internally in future.
> Does that mean that the "old" 1.7.1 code will work again in future R
> releases? That would save me from fixing quite a number of our R
> programs (we'd stick to the 1.7.1 with the old code in the mean time).

I don't know. It means that using a data frame as the rhs with the wrong
number of rows will again recycle each column. Lots of things used to
`work' pre-1.8.0, but were undocumented and not as people expected, often
resulting in corrupted data frames.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list PLEASE do read the posting guide!

About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST