s-news
[Top] [All Lists]

Re: [S] S-PLUS 2000

To: s-news@wubios.wustl.edu
Subject: Re: [S] S-PLUS 2000
From: Tim Hesterberg <timh@statsci.com>
Date: Mon, 25 Oct 1999 16:22:53 -0700 (PDT)
Reply-to: timh@statsci.com (Tim Hesterberg)
Sender: owner-s-news@wubios.wustl.edu
Leonid Gibiansky wrote about changed behavior in data.frame
between S+4.5 and S+2000.  In particular, this call:
  cdelta <- data.frame(a = NULL, b = NULL, subject = NULL)
now creates a data frame with no columns, where it previously
created a data frame with three columns.

The behavior has changed; a NULL argument now contributes zero
columns to the data frame.  The following calls will now work,
but would have failed before.

  # Create a variable only if a condition is met
  data.frame(a=1:3, b= if(condition) 2:4)

  # Use selected components of a list; include nothing for NULL components
  data.frame(x=MyList$x, y=MyList$y)  # if MyList$y is NULL

A NULL contributes no variable, because the code cannot determine
whether the variable should be numeric, factor, complex, a matrix, etc.,
or whether there should be a variable at all.

It is still possible to create a data frame with 0 rows by
specifying the type of variables, e.g.
  cdelta <- data.frame(a = numeric(0), b = numeric(0), subject = numeric(0))

The data frame code went through a major revision for S+2000,
improving speed and memory use and fixing numerous bugs.
The latter changes the behavior, and unfortunately sometimes causes
problems for code that expects the old behavior.  We apologize
for any inconvenience this causes.

========================================================
| Tim Hesterberg       Research Scientist              |
| timh@statsci.com     MathSoft, Inc.                  |
| (206)283-8802x319    1700 Westlake Ave. N, Suite 500 |
| (206)283-0347 (fax)  Seattle, WA 98109-3044, U.S.A.  |
|                      www.statsci.com/Hesterberg      |
========================================================
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] S-PLUS 2000, Gibiansky, Leonid
    • Re: [S] S-PLUS 2000, Tim Hesterberg <=