What documentation exists for R?
What documentation exists for R?
What documentation exists for R?
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 7: R Miscellanea 84<br />
computes the value 2 and returns it; the command<br />
summary(glm(y~x+z, family=binomial))<br />
fits a logistic regression model, computes some summary in<strong>for</strong>mation and returns an object<br />
of class "summary.glm" (see Section 8.1 [How should I write summary methods?], page 91).<br />
If you type ‘1+1’ or ‘summary(glm(y~x+z, family=binomial))’ at the command line<br />
the returned value is automatically printed (unless it is invisible()), but in other circumstances,<br />
such as in a source()d file or inside a function it isn’t printed unless you<br />
specifically print it.<br />
To print the value use<br />
print(1+1)<br />
or<br />
print(summary(glm(y~x+z, family=binomial)))<br />
instead, or use source(file, echo=TRUE).<br />
7.17 Why does outer() behave strangely with my function?<br />
As the help <strong>for</strong> outer() indicates, it does not work on arbitrary functions the way the<br />
apply() family does. It requires functions that are vectorized to work elementwise on<br />
arrays. As you can see by looking at the code, outer(x, y, FUN) creates two large vectors<br />
containing every possible combination of elements of x and y and then passes this to FUN<br />
all at once. Your function probably cannot handle two large vectors as parameters.<br />
If you have a function that cannot handle two vectors but can handle two scalars, then<br />
you can still use outer() but you will need to wrap your function up first, to simulate<br />
vectorized behavior. Suppose your function is<br />
foo