[R] someProblem in R-1.4.1

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed May 22 11:59:39 CEST 2002


On Wed, 22 May 2002, vito muggeo wrote:

> Hi all,
> This seems a very strange problem, but I'm running R-1.4.1 so, probably it
> has been solved in the 1.5.0 version (unfortunatly I can  neither download
> the new version nor see the archive).
>
> Assignement of column names in a matrix, works just after editing it:
>
> > M<-matrix(0,10,5)
> > dimnames(M)[[2]]<-c("a","m","m","m","m") #say
> Error: more elements supplied than there are to replace

That's incorrect.  Try

> dimnames(M)
NULL

so you are trying to replace the second element of NULL.

colnames(M)<-c("a","m","m","m","m") #say

will work, as will
dimnames(M) <- list(NULL, c("a","m","m","m","m"))

> > fix(M)

That adds colnames, as it uses the internals of edit.data.frame.

> > dimnames(M)[[2]]<-c("a","m","m","m","m") #works

This is still the same in 1.5.0.


-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list