I\'d like to be able to see the function that\'s used when I use str(), as I\'d like to modify it a bit for my own purposes as another function.
When I type s
You could also do it like this:
> methods(by)
[1] by.data.frame by.default
> getS3method("by", "data.frame")
function (data, INDICES, FUN, ..., simplify = TRUE)
{
...
}
<environment: namespace:base>
You want methods()
for an S3 generic such as str()
:
> methods(str)
[1] str.data.frame* str.Date* str.default*
[4] str.dendrogram* str.logLik* str.POSIXt*
Non-visible functions are asterisked
Using getAnywhere(str)
is not really helpful because str()
is visible so you get the same result if you just run str
at the prompt. You need getAnywhere()
to look at the hidden methods listed above:
getAnywhere(str.default)
for example.
Shame you need to know what kind of generic a function is to list the methods; seems user-friendliness would be improved if R didn't care what kind of method type was supplied to one or other of these functions.