Skip to content
Prev 154 / 63424 Next

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

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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-