I have the following function
f <- function {
...
model <- lm(rttx[,1] ~ rttx[,2] + 0);
summary(model);
...
}
while summary(model) shows the summary if I execute the function line by line
in the Command Line Interface, if I call f() summary is silent
how to solve it? or is there workaround?
thanks in advance
Ulisses
Debian GNU/Linux: a dream come true
-----------------------------------------------------------------------------
"Computers are useless. They can only give answers." Pablo
Picasso
---> Visita http://www.valux.org/ para saber acerca de la <---
---> Asociaci?n Valenciana de Usuarios de Linux <---
On Wed, 14 Jan 2004 uaca at alumni.uv.es wrote:> > I have the following function > > f <- function { > > ... > > model <- lm(rttx[,1] ~ rttx[,2] + 0); > summary(model); > > ... > } > > while summary(model) shows the summary if I execute the function line by line > in the Command Line Interface, if I call f() summary is silent > > how to solve it? or is there workaround?You didn't do anything with the return value from summary(.lm). You need to print() it, which happens automatically at the command line. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Ulisses, could you be a little more specific ?. What OS, R version and data you are using ? I've tested this as an example and works fine (at least for me):> f<-function(){x<-1:10 y<-rnorm(10) s<-lm(y~x+0) summary(s) }>f()Call: lm(formula = y ~ x + 0) Residuals: Min 1Q Median 3Q Max -1.8488 -0.6693 0.2065 0.5043 1.5903 Coefficients: Estimate Std. Error t value Pr(>|t|) x 0.07631 0.05400 1.413 0.191 Rodrigo Abt B., SII, Chile. --- Date: Wed, 14 Jan 2004 09:24:22 +0100 From: uaca at alumni.uv.es Subject: [R] summary() within a function To: r-help at stat.math.ethz.ch Message-ID: <20040114082422.GA18168 at pusa.informat.uv.es> Content-Type: text/plain; charset=iso-8859-1 I have the following function f <- function { ... model <- lm(rttx[,1] ~ rttx[,2] + 0); summary(model); ... } while summary(model) shows the summary if I execute the function line by line in the Command Line Interface, if I call f() summary is silent how to solve it? or is there workaround? thanks in advance Ulisses Debian GNU/Linux: a dream come true ---------------------------------------------------------------------------- - "Computers are useless. They can only give answers." Pablo Picasso ---> Visita http://www.valux.org/ para saber acerca de la <--- ---> Asociacisn Valenciana de Usuarios de Linux <---
Ulisses, by the way I forgot something, If your function doesn?t end with
summary you'll have to print it explicitly
f<-function(){
x<-1:10
y<-rnorm(10)
s<-lm(y~x+0)
...
print(summary(s))
...
}
---
Date: Wed, 14 Jan 2004 09:24:22 +0100
From: uaca at alumni.uv.es
Subject: [R] summary() within a function
To: r-help at stat.math.ethz.ch
Message-ID: <20040114082422.GA18168 at pusa.informat.uv.es>
Content-Type: text/plain; charset=iso-8859-1
I have the following function
f <- function {
...
model <- lm(rttx[,1] ~ rttx[,2] + 0);
summary(model);
...
}
while summary(model) shows the summary if I execute the function line by
line
in the Command Line Interface, if I call f() summary is silent
how to solve it? or is there workaround?
thanks in advance
Ulisses
Debian GNU/Linux: a dream come true
----------------------------------------------------------------------------
-
"Computers are useless. They can only give answers." Pablo
Picasso
---> Visita http://www.valux.org/ para saber acerca de la <---
---> Asociacisn Valenciana de Usuarios de Linux <---
Rodrigo Abt,
SII, Chile
-----Mensaje original-----
De: Rodrigo Abt [mailto:rodrigo.abt at sii.cl]
Enviado el: Mi?rcoles, 14 de Enero de 2004 12:36
Para: 'Lista de Correo de R'
CC: 'uaca at alumni.uv.es'
Asunto: Re: [R] summary() within a function
Ulisses, could you be a little more specific ?. What OS, R version and data
you are using ?
I've tested this as an example and works fine (at least for me):
> f<-function(){
x<-1:10
y<-rnorm(10)
s<-lm(y~x+0)
summary(s)
}
>f()
Call:
lm(formula = y ~ x + 0)
Residuals:
Min 1Q Median 3Q Max
-1.8488 -0.6693 0.2065 0.5043 1.5903
Coefficients:
Estimate Std. Error t value Pr(>|t|)
x 0.07631 0.05400 1.413 0.191
Rodrigo Abt B.,
SII, Chile.
---
Date: Wed, 14 Jan 2004 09:24:22 +0100
From: uaca at alumni.uv.es
Subject: [R] summary() within a function
To: r-help at stat.math.ethz.ch
Message-ID: <20040114082422.GA18168 at pusa.informat.uv.es>
Content-Type: text/plain; charset=iso-8859-1
I have the following function
f <- function {
...
model <- lm(rttx[,1] ~ rttx[,2] + 0);
summary(model);
...
}
while summary(model) shows the summary if I execute the function line by
line
in the Command Line Interface, if I call f() summary is silent
how to solve it? or is there workaround?
thanks in advance
Ulisses
Debian GNU/Linux: a dream come true
----------------------------------------------------------------------------
-
"Computers are useless. They can only give answers." Pablo
Picasso
---> Visita http://www.valux.org/ para saber acerca de la <---
---> Asociacisn Valenciana de Usuarios de Linux <---