On Thu, 28 Apr 2005, Omar Lakkis wrote:

r
[1] open   settle
<0 rows> (or 0-length row.names)
class(r)
[1] "data.frame"

this is an empty data.frame I get back from a sql statement that
returns an empty result set. How can I create such an empty data.frame
using the data.frame() constructor?
I want to have a data.frame with 0 rows but named empty columns.

Is this what you want?

x <- data.frame(a=character(0), b=numeric(0))
x
[1] a b
<0 rows> (or 0-length row.names)
names(x)
[1] "a" "b"



--
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to