Message-ID: <PU4P216MB1568CB60C7B91A45E16B92FFC8C59@PU4P216MB1568.KORP216.PROD.OUTLOOK.COM>
Date: 2023-01-20T17:10:59Z
From: akshay kulkarni
Subject: function doesn't exists but still runs.....
In-Reply-To: <CAHqSRuTCBqh84FHg7=Xmd9qHxUiAN3Y4zBJbkAR3dRWhggu89Q@mail.gmail.com>
Dear Bill,
Thanks for your reply...If I run selenium() in debug mode, java_check() should work inside of selenium(), right?
Any other points to be considered when running selenium() in debug mode?
THanking you,
yours sincerely
AKSHAY M KULKARNI
________________________________
From: Bill Dunlap <williamwdunlap at gmail.com>
Sent: Friday, January 20, 2023 5:32 AM
To: akshay kulkarni <akshay_e4 at hotmail.com>
Cc: R help Mailing list <r-help at r-project.org>
Subject: Re: [R] function doesn't exists but still runs.....
Look into R's scoping rules. E.g., https://bookdown.org/rdpeng/rprogdatascience/scoping-rules-of-r.html.
* When a function looks up a name, it looks it up in the environment in which the function was defined.
* Functions in a package are generally defined in the package's environment (although sometimes they are in a descendent of the parent's environment).
* When one searches an environment for a name, if it is not found in the environment the search continues in the parent environment of that environment, recursively until the parent environment is the empty environment.
> with(environment(wdman::selenium), java_check)
function ()
{
javapath <- Sys.which("java")
if (identical(unname(javapath), "")) {
stop("PATH to JAVA not found. Please check JAVA is installed.")
}
javapath
}
<bytecode: 0x000001fd0ab826a8>
<environment: namespace:wdman>
-Bill
On Thu, Jan 19, 2023 at 2:28 PM akshay kulkarni <akshay_e4 at hotmail.com<mailto:akshay_e4 at hotmail.com>> wrote:
dear members,
I am using the RSelenium package which uses the function selenium() from the wdman package. The selenium function contains the function java_check at line 12. If I try to run it, it throws an error:
> javapath <- java_check()
Error in java_check() : could not find function "java_check"
Also:
> exists("java_check")
[1] FALSE
But when I run selenium(), it works fine....
How do you explain this conundrum? You can refer to this link: https://github.com/ropensci/wdman/issues/15
Specifically what concept of R explains this weird behaviour?
Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org<mailto:R-help at 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]]