R-alpha: Re: R-beta: ls.print

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Tue, 13 May 1997 08:16:30 +0200


>>>>> Ennapadam Venkatraman writes:

> ls.print produces error that I don't seem to be able to trace.
> Output of the commands as follows: (hyeung is a 24x2 matrix of data)

> -------------------------------------------------
>> summary(hyeung)
>        x.1             x.2
>  Min.   : 28.0   Min.   : 10.0
>  1st Qu.: 72.0   1st Qu.: 87.5
>  Median : 86.5   Median : 92.5
>  Mean   : 81.0   Mean   : 82.5
>  3rd Qu.: 97.0   3rd Qu.:100.0
>  Max.   :100.0   Max.   :100.0

>> summary(lsfit(hyeung[,1],hyeung[,2]))
>           Length Class  Mode
> coef       2     -none- numeric
> residuals 24     -none- numeric
> intercept  1     -none- logical
> qr         6     -none- list

>> ls.print(lsfit(hyeung[,1],hyeung[,2]))
> trace: ls.print(lsfit(hyeung[, 1], hyeung[, 2]))
> Error: missing value in ``n1 : n2''

> -------------------------------------------------

> E. S. Venkatraman (venkat@biosta.mskcc.org)

The problem seems to be that

	ncol(ls.out$residuals)

gives NULL if ls.out is a vector.  An easy fix is to replace each
occurrence of ncol in ls.print() by NCOL.

A patch is appended below.

Btw, my help file for NCOL comes up with `.COL' rather than `NCOL'.  Can
anyone verify that?

-k

*** src/library/base/funs/lsfit.orig	Tue May 13 07:54:24 1997
--- src/library/base/funs/lsfit	Tue May 13 07:51:19 1997
*************** ls.print <- function(ls.out, digits=4, p
*** 256,265 ****
  
  	# construct coef table
  
! 	coef.table <- as.list(1:ncol(ls.out$residuals))
! 	if(ncol(ls.out$residuals)==1) coef <- matrix(ls.out$coef, nc=1)
  	else coef <- ls.out$coef
! 	for(i in 1:ncol(ls.out$residuals)) {
  		covmat <- (resss[i]/(n[i]-p)) * (qrinv%*%t(qrinv))
  		coef.table[[i]] <- cbind(coef[, i], diag(covmat)^.5,
  			coef[, i]/diag(covmat)^.5,
--- 256,265 ----
  
  	# construct coef table
  
! 	coef.table <- as.list(1:NCOL(ls.out$residuals))
! 	if(NCOL(ls.out$residuals)==1) coef <- matrix(ls.out$coef, nc=1)
  	else coef <- ls.out$coef
! 	for(i in 1:NCOL(ls.out$residuals)) {
  		covmat <- (resss[i]/(n[i]-p)) * (qrinv%*%t(qrinv))
  		coef.table[[i]] <- cbind(coef[, i], diag(covmat)^.5,
  			coef[, i]/diag(covmat)^.5,
*************** ls.print <- function(ls.out, digits=4, p
*** 270,276 ****
  		#print results
  
  		if(print.it) {
! 			if(ncol(ls.out$residuals)>1)
  				cat("Response:", colnames(ls.out$residuals)[i],
  				"\n\n")
  			cat(paste("Residual Standard Error=", format(round(
--- 270,276 ----
  		#print results
  
  		if(print.it) {
! 			if(NCOL(ls.out$residuals)>1)
  				cat("Response:", colnames(ls.out$residuals)[i],
  				"\n\n")
  			cat(paste("Residual Standard Error=", format(round(
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel 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-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-