Cloud Stack Ninja

How can we see all available parameters (or view documentation more generally) for a class method?

For example, if we look at arguments for print()

?print

x   
an object used to select a method.

... 
further arguments passed to or from other methods.

quote   
logical, indicating whether or not strings should be printed with surrounding quotes.


-- leaving others out for brevity --
 
useSource   
logical indicating if internally stored source should be used for printing when present, e.g., if options(keep.source = TRUE) has been in use.

Note that we do not see any documentation for the parameter max_n.

Now suppose we call print() on something of class xml_nodes, e.g:

library(rvest)
library(dplyr)

# Generate an object of class xml_nodes
a <- rep("<p></p>", 30) %>% 
  paste0(collapse="") %>% 
  read_html %>% 
  html_nodes("p")

class(a)
# [1] "xml_nodeset"

a is of class xml_nodeset, and if we call print(a), it prints only 20 results, and that's because (I think) the xml_nodeset class is configured such that when print is called on it, it will only return 20 results. (the '20' number can be changed via the max_n parameter).

How do we find the specific documentation for how print will behave when called on the object of class xml_nodeset? (preferably via RStudio/manuals)

Note that the example above is just a random example, I would like to find a general way of finding documentation for all class methods



Read more here: https://stackoverflow.com/questions/64409056/how-to-see-available-parameters-and-documentation-for-class-method-in-r

Content Attribution

This content was originally published by stevec at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: