IV) You probably don't want to print() m at the end: the REPL will
print it automatically in interactive top level calls and it will be
rather noisy if you start wrapping this in other calls.
Hope this helps,
Michael
On Apr 4, 2012, at 11:13 AM, Sam Steingold <sds at gnu.org> wrote:
I am sure a common need is to plot a scatterplot with some fitted
line(s) and maybe save to a file.
I have this:
plot.glm <- function (x, y, file = NULL, xlab =
deparse(substitute(x)),
ylab = deparse(substitute(y)), main = NULL) {
m <- glm(y ~ x)
if (!is.null(file))
pdf(file = file)
plot(x, y, xlab = xlab, ylab = ylab, main = main)
lines(x, y = m$fitted.values, col = "green")
if (!is.null(file))
dev.off()
print(m)
}
is there a better/easier/more general way?
--