[Rd] bad variable names when printing a data frame containing a matrix (PR#10730)

timh at insightful.com timh at insightful.com
Sat Feb 9 01:50:08 CET 2008


library(glmpath)
data(heart.data)
# heart.data is a list, $y a vector, $x a matrix
data <- data.frame(x=I(heart.data$x), y = heart.data$y)
> data[1:2,]
    x.1   x.2   x.3   x.4   x.5   x.6   x.7   x.8   x.9 y
1   160    12  5.73 23.11     1    49  25.3  97.2    52 1
2   144  0.01  4.41 28.61     0    55 28.87  2.06    63 1
> dimnames(heart.data$x)[[2]]
[1] "sbp"       "tobacco"   "ldl"       "adiposity" "famhist"   "typea"    
[7] "obesity"   "alcohol"   "age"      

Note that the printed variable names do not use the column names
of the matrix.

In contrast, in S-PLUS the names are used; the printout begins:
   x.sbp x.tobacco  x.ldl x.adiposity x.famhist x.typea x.obesity x.alcohol 


--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = 
 major = 2
 minor = 6.1
 year = 2007
 month = 11
 day = 26
 svn rev = 43537
 language = R
 version.string = R version 2.6.1 (2007-11-26)

Windows XP (build 2600) Service Pack 2.0

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

Search Path:
 .GlobalEnv, package:glmpath, package:survival, package:splines, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base



More information about the R-devel mailing list