[R] weird pasting of ".value" when list is returned

Daniel Malter daniel at umd.edu
Sat Dec 13 11:39:48 CET 2008


Hi Mark, I cannot explain why it does it. But if you use data.frame instead,
it works.

Cheers,
Daniel

f.lmmultenhanced <-
function(response, pred1, pred2)
{

         regmod <- lm(response ~ pred1 + pred2)
         lmsum <- summary(regmod)

         imbcoef<-lmsum$coefficients[2,1]
         retcoef<-lmsum$coefficients[3,1]

         imbpval<-lmsum$coefficients[2,4]
         retpval<-lmsum$coefficients[3,4]

         Fstat<-lmsum$fstatistic[1]
fpval<-pf(Fstat,lmsum$fstatistic[2],lmsum$fstatistic[3],lower=FALSE)

return(list(categrsp=response,pred1=pred1,pred2=pred2,regmod=regmod,rest=dat
a.frame(KARLGUSTAV=fpval,IMBCOEF=imbcoef,RETCOEF=retcoef,IMBPVAL=imbpval,RET
PVAL=retpval)))

  }

x <- 10 + 1:100
y <- 5 +  seq(2,200,by=2)
z <- 2*x + 3*y + rnorm(100)

temp <- f.lmmultenhanced(x,y,z)
print(temp) 


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von markleeds at verizon.net
Gesendet: Saturday, December 13, 2008 1:54 AM
An: r-help at r-project.org
Betreff: [R] weird pasting of ".value" when list is returned

could someone explain why the name of FPVAL gets " .value" concatenated onto
it when the code below is run and temp is returned.
I've been trying to figure this out for too long. It doesn't matter when I
put the FPVAL in the return statement. It happens regardless of
whether it's first or last.   Thanks.

f.lmmultenhanced <-
function(response, pred1, pred2)

{

         regmod <- lm(response ~ pred1 + pred2)
         lmsum <- summary(regmod)

         imbcoef<-lmsum$coefficients[2,1]
         retcoef<-lmsum$coefficients[3,1]

         imbpval<-lmsum$coefficients[2,4]
         retpval<-lmsum$coefficients[3,4]

         Fstat<-lmsum$fstatistic[1]
 
fpval<-pf(Fstat,lmsum$fstatistic[2],lmsum$fstatistic[3],lower=FALSE)

 
return(list(categrsp=response,pred1=pred1,pred2=pred2,regmod=regmod,
 
rest=c("FPVAL"=fpval,"IMBCOEF"=imbcoef,"RETCOEF"=retcoef,"IMBPVAL"=imbpval,"
RETPVAL"=retpval)
                     ))

  }


x <- 10 + 1:100
y <- 5 +  seq(2,200,by=2)
z <- 2*x + 3*y + rnorm(100)

temp <- f.lmmultenhanced(x,y,z)
print(temp)

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list