We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a question regarding the usage of pryr functions in own code. Following is a function I've created: f <- function(var) {pryr::ftype(var)}
f <- function(var) {pryr::ftype(var)}
Calling "ftype" directly for 't.data.frame' results in an expected output:
pryr::ftype(t.data.frame) [1] "s3" "method"`
Calling the same 't.data.frame' from my function prints a wrong result:
f(t.data.frame) [1] "function"
Is there some trick for "S3 method" recognition ?
The text was updated successfully, but these errors were encountered:
@dhuebner you always ask hard and good questions! :) I couldn't figure it out. I sent an email to Hadely (author of pryr) and will keep you posted.
Sorry, something went wrong.
Hi Dennis @dhuebner,
ftype uses parent.frame() in order to derive the type (in this case, the environment of the function f call).
ftype
parent.frame()
f
You may use this workaround in order to go one level back (or, for example, to the global environment, if env=.GlobalEnv):
> f <- function(var, env=parent.frame()) { + eval(substitute(pryr::ftype(var)), envir = env) + } > > f(t.data.frame) [1] "s3" "method"
Hope this helps.
Regards, Alex
No branches or pull requests
I have a question regarding the usage of pryr functions in own code.
Following is a function I've created:
f <- function(var) {pryr::ftype(var)}
Calling "ftype" directly for 't.data.frame' results in an expected output:
Calling the same 't.data.frame' from my function prints a wrong result:
Is there some trick for "S3 method" recognition ?
The text was updated successfully, but these errors were encountered: