[Rd] cbind(deparse.level=2,...) problems

William Dunlap wdunlap at tibco.com
Tue Feb 9 18:56:03 CET 2010


Should the deparse.level=2 argument to cbind
and rbind be abandoned?  It is minimally documented,
not used in any CRAN package, and causes some problems.
E.g.,

(a) If a matrix input has row names but not column names
    cbind(deparse.level=2,...) stops.
>
m<-matrix(11:14,nrow=2,ncol=2,dimnames=list(Row=c("R1","R2"),Col=charact
er()))
> cbind(m, 101:102, deparse.level=2)
Error in cbind(m, 101:102, deparse.level = 2) :
  SET_STRING_ELT() can only be applied to a 'character vector', not a
'NULL'

(b) If no argument is tagged then deparse.level=2
    makes no column names, while deparse.level=1 makes
    names for for the simple cases (where the argument
    is a name):
> x<-1:3
> cbind(x, 11:13, deparse.level=1)
     x
[1,] 1 11
[2,] 2 12
[3,] 3 13
> cbind(x, 11:13, deparse.level=2)
     [,1] [,2]
[1,]    1   11
[2,]    2   12
[3,]    3   13

     (If one argument is tagged, teens=11:13, then
     deparse.level=2 will name columns that
     deparse.level=1 will not, like x+1, which I
     think is the intended behavior.)


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



More information about the R-devel mailing list