match_params {postpack} | R Documentation |
Find matching node names
Description
Returns all the node names stored in a mcmc.list
object that match a provided string.
Usage
match_params(post, params, type = "base_index", auto_escape = TRUE)
Arguments
post |
A |
params |
A vector of regular expressions specifying the nodes to match.
Accepts multi-element vectors to match more than one node at a time.
See examples and |
type |
Format of returned matches; only two options are accepted:
|
auto_escape |
Automatically escape |
Details
This function is called as one of the first steps in many of the more downstream functions in this package. It is thus fairly important to get used to how the regular expressions work. This function can be used directly to hone in on the correct regular expression. See the examples below.
Value
A character vector with all node names in post
that match params
, formatted as requested by type
..
If no matches are found, an error will be returned with
the base node names found in post
to help the next try.
Examples
# load example mcmc.list
data(cjs)
# these produce same output b/c of regex pattern matching
match_params(cjs, params = c("b0", "b1"))
match_params(cjs, params = c("b"))
# return only base names, not indices as well
match_params(cjs, params = "b", type = "base_only")
# force a match to start with B
match_params(cjs, "^B")
# force a match to end with 0
match_params(cjs, "0$")
# use a wild card to get b0[3] and b1[3]
match_params(cjs, "b.[3]")
# repeat a wild card
match_params(cjs, "s.+0")
# turn off auto escape to use [] in regex syntax rather than matching them as text
match_params(cjs, params = "[:digit:]$", auto_escape = FALSE)
# pass a dot to match all (same as get_params)
match_params(cjs, ".")