[R] on lexical scoping....

akshay kulkarni @k@h@y_e4 @end|ng |rom hotm@||@com
Wed Apr 5 19:04:04 CEST 2023


Dear richard,
                        Bulls eye! thanks for your pointed reply...!

THanking you,
Yours sincerely,
AKSHAY M KULKARNI
________________________________
From: Richard O'Keefe <raoknz using gmail.com>
Sent: Wednesday, April 5, 2023 10:30 AM
To: akshay kulkarni <akshay_e4 using hotmail.com>
Cc: R help Mailing list <r-help using r-project.org>
Subject: Re: [R] on lexical scoping....

R *does* search the environment stack.

> search()
[1] ".GlobalEnv"        "package:stats"     "package:graphics"
[4] "package:grDevices" "package:utils"     "package:datasets"
[7] "package:methods"   "Autoloads"         "package:base

What you seem to be missing is that a package may contain
bindings that it does not export, as the wording of this
error message reminds us:
> utils::y
Error: 'y' is not an exported object from 'namespace:utils'

So when package/namespace goes onto the environment stack,
it's only the *exported* bindings that become visible.



On Wed, 5 Apr 2023 at 01:56, akshay kulkarni <akshay_e4 using hotmail.com<mailto:akshay_e4 using hotmail.com>> wrote:
Dear Members,
                             I have the following code typed at the console prompt:

y   <-   x*10

X has not been defined and the above code throws an object not found error. That is, the global environment does not contain x. Why doesn't it look further in the environment stack, like that of packages? There are thousands of packages that contain the variable named  x. Of course, that happens if the above code is in a function (or does it?).

What concept of R is at work in this dichotomy?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

        [[alternative HTML version deleted]]

______________________________________________
R-help using r-project.org<mailto:R-help using r-project.org> mailing list -- To UNSUBSCRIBE and more, see
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.

	[[alternative HTML version deleted]]



More information about the R-help mailing list