[S] plotting a regression object: solution

Matthew Wiener (mcw@ln.nimh.nih.gov)
Tue, 28 Apr 1998 15:50:19 -0400 (EDT)

Hi the solution is to assign "dframe" to frame 1, as in:

assign("dframe", dframe,frame=1).

This gets around Splus's arcane scoping rules.

Thanks to all those who replied.

matt Wiener

---------- Forwarded message ----------
Date: Tue, 28 Apr 1998 14:15:40 -0400 (EDT)
From: Matthew Wiener <mcw@ln.nimh.nih.gov>
To: s-news@wubios.wustl.edu
Subject: plotting a regression object

Hello, all.

I know this is a basic question, but I've been through the documentation
and can't find the answer.

In the following code:

function(cell, n = 1) {
cell <- cell[cell$lat < 999, ]
a <- tapply(cell$lat, cell$stim, mean)
b <- tapply(cell$lat, cell$stim, var) #
mean.sp <- tapply(cell$sp, cell$stim, mean)
g <- 1 - 1/b
dframe <- as.data.frame(cbind(a, b, mean.sp, g))
if(n == 1) {
(not important for this question)
if(n == 2) {
par(mfrow = c(2, 3))
reg1 <- lm(log(dframe$b) ~ log(dframe$a))
plot(lm(log(dframe$b) ~ log(dframe$a)))
par(mfrow = c(1, 1)) #

with n=2, I get an error in the plot statement:

Error: Object "dframe" not found.

I get the same error if I say plot(reg1).

The examples in the documentation all seem to look exactly like this.

Thanks for your help. If people reply privately, I'll post a summary; if
they post to the group, I won't.


This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news