It has to do with the "NA"s in dimnames, but I don't know why this is a problem. If you either got rid of dimnames or assigned actual names, this works fine.
Ravi. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Robin Hankin > Sent: Wednesday, October 19, 2005 10:55 AM > To: RHelp > Subject: [R] diag() problem > > Hi > > I have a matrix "u", for which diag() gives an error: > > u <- structure(c(5.42334674128216, -2.31319389204264, -5.83059042218476, > -1.64112369640695, -2.31319389212801, 3.22737617646609, > 1.85200668021569, > -0.57102273078531, -5.83059042231881, 1.85200668008156, > 11.9488923894962, > -3.5525537165941, -1.64112369587405, -0.571022730886046, > -3.55255371755604, > 10.0989829379577), .Dim = c(4, 4), .Dimnames = list(c("constant", > NA, NA, NA), c("constant", NA, NA, NA))) > > > u > constant <NA> <NA> <NA> > constant 5.423347 -2.3131939 -5.830590 -1.6411237 > <NA> -2.313194 3.2273762 1.852007 -0.5710227 > <NA> -5.830590 1.8520067 11.948892 -3.5525537 > <NA> -1.641124 -0.5710227 -3.552554 10.0989829 > > is.matrix(u) > [1] TRUE > > diag(u) > Error in if (is.list(nms) && !any(sapply(nms, is.null)) && all((nm <- > nms[[1]][1:m]) == : > missing value where TRUE/FALSE needed > > > > > > What's going on here? > > > > > > R.version > _ > platform powerpc-apple-darwin8.2.0 > arch powerpc > os darwin8.2.0 > system powerpc, darwin8.2.0 > status > major 2 > minor 2.0 > year 2005 > month 10 > day 06 > svn rev 35749 > language R > > > > > > > -- > Robin Hankin > Uncertainty Analyst > National Oceanography Centre, Southampton > European Way, Southampton SO14 3ZH, UK > tel 023-8059-7743 > > ______________________________________________ > [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 ______________________________________________ [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
