R-alpha: row.names<-

Douglas Bates (bates@stat.wisc.edu)
Thu, 19 Dec 1996 13:25:40 -0600 (CST)


Message-Id: <m0vao68-000hiAC@franz.stat.wisc.edu>
Date: Thu, 19 Dec 1996 13:25:40 -0600 (CST)
From: Douglas Bates <bates@stat.wisc.edu>
To: R-testers <r-testers@stat.math.ethz.ch>
Subject: R-alpha: row.names<-

After re-constructing the data frame containing the grades in my class
three times, I decided to look at the definition of row.names<-.  It
is missing an "x" at the end.

> get("row.names<-")
function (x, value) 
{
	if (!is.data.frame(x)) 
		x <- data.frame(x, row.names = value)
	else attr(x, "row.names") <- as.character(value)
}

should be

"row.names<-" <-
function (x, value) 
{
	if (!is.data.frame(x)) 
		x <- data.frame(x, row.names = value)
	else attr(x, "row.names") <- as.character(value)
	x
}

although I think I would write it

"row.names<-" <-
function(x, value)
{
  if (!is.data.frame(x)) 
    return(data.frame(x, row.names = value))
  attr(x, "row.names") <- as.character(value)
  x
}

You would have thought I would have checked this after blowing away my
grades the second time but noooo.  I had to do it *three* times before
it occurred to me that something was amiss.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-