pub unsafe fn dollar_extract(target: SEXP, name: &str) -> Result<SEXP, String>Expand description
Build and evaluate target$name — the R $ extraction operator.
This is a convenience wrapper that avoids hand-rolling
Rf_install("$") + Rf_lang3(...) + R_tryEvalSilent(...) ladders.
Equivalent to:
ⓘ
RCall::new("$")
.arg(target)
.arg(SEXP::scalar_string_from_str(name))
.eval_base()but uses the more direct LANGSXP form internally and protects all intermediate allocations via RAII.
§Safety
- Must be called from the R main thread.
targetmust be a valid SEXP (typically a list, environment, or S4 object that supports$extraction).
§Returns
Ok(SEXP)with the extracted value (unprotected — caller should protect if needed).Err(String)with the R error message if$extraction fails or the evaluation errors.