You don't need to take any of the four. When you call on read_xml
, the function looks at the class of the first argument (x, in this case) (e.g., a character string, a connection), and calls the function for that class. Basically, when you do read_xml(x)
, the function calls read_xml.[class(x)](x)
.
If the argument has more than one class, UseMethods
will cycle through all the classes, from first to last, until if finds one with a method. Some functions might also have a default
method, which is used if no other, more specific method, is found. read_xml
, as you can see, doesn't have one. If you try using read_xml
with a first argument that is, say, numeric, you'll get this error from UseMethod
:
Error in UseMethod("read_xml") :
no applicable method for 'read_xml' applied to an object of class "c('double', 'numeric')"
As noted in the question you linked to, you can see the code for the specific class functions by using getAnywhere
.