The most interesting thing in this thread for me was "within()" - that is what 
I want 99% of the time, but I had only ever heard of with()

A real boon! Thanks Bill V!

The help for within gives this example for with(), which seems unnecessary, as 
glm supports data=

with(anorexia, {
    anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt), family = gaussian)
    summary(anorex.1)
})

especially when this is easier to read:
  m <- glm(Postwt ~ Prewt + Treat + offset(Prewt), family = gaussian, 
data=anorexia)
  summary(m)

The Rd file also has (just?) one example for within… I suggest deleting the 
anorexia example so the within example comes first, and perhaps supplementing 
with

## Not run: 
# More advanced example of usage (not run)
model1  <- glm.nb(Cells ~ Cryogel*Day, data = myData)
myData2 <- within(myData, Cryogel <- relevel(Cryogel, ref = "2"))
model2  <- update(model1, data = myData1) 
## End(Not run)


Also, the help page for transform does not back link to within… That would be 
helpful. It also uses an example with attach, which might encourage less good 
habits.

Best wishes, and thanks,
tim
PS   : How does one best contribute to help files?
PPS: If R was to go to google summer of code, apart from helpful help, my 
wishlist would prioritise standardising all common functions to (where possible)
1. Have a formula interface
2. Support “data=“
3. Use a uniform na handling, with examples

Diverse NA behavior catches most of our students out (now all three departments 
of our school using R exclusively at the PG level)
NA behaviour can be
na.rm=     as in rowMeans(na.rm=T))
use=         as in an cor(use=“every”)   # with well documented effects in 
?cor(), and all legal options  shown 
(everything|all.obs|complete.obs|na.or.complete|pairwise.complete.obs)
na.action=  as in t.test(na.action=“na.omit”) # with no examples in ?t.test, 
nor a list of legal values

Likewise it would help reduce confusion when
plot(~Source, data=Df) # works
# but
boxplot(~Source, data=Df)
# Error in boxplot.formula(~Source, data = Df) : 
#  'formula' missing or incorrect

The formula isn’t missing or illformed, it’s that boxplot requires formulae to 
have something on the left hand side. 

best, t
______________________________________________
R-help@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.

Reply via email to