xp_call_name | R Documentation |
Often, it is more helpful to tailor the message
of a lint to record
which function was matched by the lint logic. This function encapsulates
the logic to pull out the matched call in common situations.
xp_call_name(expr, depth = 1L, condition = NULL)
expr |
An |
depth |
Integer, default |
condition |
An additional (XPath condition on the |
xml_from_code <- function(str) {
xml2::read_xml(xmlparsedata::xml_parse_data(parse(text = str, keep.source = TRUE)))
}
xml <- xml_from_code("sum(1:10)")
xp_call_name(xml, depth = 2L)
xp_call_name(xml2::xml_find_first(xml, "expr"))
xml <- xml_from_code(c("sum(1:10)", "sd(1:10)"))
xp_call_name(xml, depth = 2L, condition = "text() = 'sum'")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.