Well I spot this when I actually made a mistake. I want to get the manual page of mgcv.FAQ
, but I
library(mgcv)
;?mgcv-faq
.But, R strangely directs me to the doc page as if I have done ?Arithmetic
.
What is going on? After I do library(mgcv)
, putting ?mgcv-faq
now gives an error:
#Error in eval(argExpr, envir) : object 'mgcv' not found
#Error in .signatureFromCall(fdef, expr, envir, doEval) :
# error in trying to evaluate the expression for argument ‘e1’ (mgcv)
Can anyone explain this behavior?
sessionInfo()
before library(mgcv)
:
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblas.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.4
attached base packages:
[1] stats graphics grDevices utils datasets methods base
sessionInfo()
after library(mgcv)
:
## only shows what is different from the above
other attached packages:
[1] mgcv_1.8-24 nlme_3.1-137
loaded via a namespace (and not attached):
[1] compiler_3.4.4 Matrix_1.2-14 tools_3.4.4 grid_3.4.4
[5] lattice_0.20-35
I don't have Rstudio, so I run R in the terminal. And the manual page is displayed in the terminal.
You can reproduce this with:
expr <- quote(mgcv-faq)
utils:::.helpForCall(expr, parent.frame())
.helpForCall
gets called by ?
internally with this input.
Now, if the expression does not contain ::
or :::
calls, .helpForCall
extracts the symbol to look up by doing
expr[[1L]]
#`-`
without checking the length of the expression.
The -
operator is first in the expression because the expression is parsed to function syntax.
Why does this happen? Because ?
should be able to handle ::
and :::
in its input and nobody thought of handling a user error such as yours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With