Take this object as an example:
expr <- substitute(mean(exp(sqrt(.)), .))
It is a nested list. I want to find every element that matches
Using a recursive function:
convert.call <- function(x, replacement) { if (is.call(x)) as.call(lapply(x, convert.call, replacement=replacement)) else if (identical(x, quote(.))) as.name(replacement) else x } convert.call(expr, "x") # mean(exp(sqrt(x)), x)