Skip to content

weird pasting of ".value" when list is returned

3 messages · Mark Leeds, Daniel Malter, Charles C. Berry

#
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)
#
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.
#
On Sat, 13 Dec 2008, markleeds at verizon.net wrote:

            
Mark,


It is because the sole element of fpval is named 'value'. Check this:
$a
[1] 1

$b
       x.value y.nother.name
             1             2

HTH,

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901