It does work correctly:
> names(tdf)
[1] "" ""
The thing you have overlooked is that data frames are required to have
non-empty (not 'zero-length': yours has length 2) names, and the print
method has created some (as data.frame will if you give unnamed
arguments).
Please be careful to distinguish between an object and its printed
representation.
On Fri, 28 Aug 2009, vitosmail at rambler.ru wrote:
> Full_Name: Spinu Vitalie
> Version: 2.9.0
> OS: Windows
> Submission from: (NULL) (130.115.113.15)
>
>
> In assignment of "zero length" names to data.frame:
>
>> tdf <- data.frame(rbind(c(1, 2), c(1, 2)))
>> names(tdf) <- c("", "")
>> tdf
> structure(c("1", "1"), class = "AsIs")
structure(c("2", "2"), class = "AsIs")
> 1 1
2
> 2 1
2
>
> For vectors it works nicely:
>
>> tv <- c(1, 2)
>> names(tv) <- c("", "")
>> tv
>
> 1 2
>
>
>
>
>> sessionInfo()
> R version 2.9.0 (2009-04-17)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics uti
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
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