S3Assignments: Identify S3 class assignments in R code

View source: R/S3Assigns.R

S3AssignmentsR Documentation

Identify S3 class assignments in R code

Description

This function analyzes an R function's code and finds the assignment of class attributes to any object. These are S3 class definitions.

Usage

S3Assignments(code, walker = mkS3AssignWalker(...), ...)

Arguments

code

the R code to search for S3 class assignments

walker

the codetools-related object that processes the AST to identify and collect the S3 assignments.

...

additional arguments passed to mkS3AssignWalker

Value

If asNode is FALSE, a character vector that can also include NA values.

If asNode is TRUE, a list containing the rstatic node objects from the abstract syntax tree (AST) corresponding to the S3 class assignments.

Author(s)

Duncan Temple Lang

Examples

f2 =
function(x)
{
    ans = c(low = min(x), high = max(x))
    class(ans) = "Extent"
    ans
}


S3Assignments(f2)

f4 =
function(x)
    structure(c(low = min(x), high = max(x)), class = c("Extent", "1D"))

S3Assignments(f4)

duncantl/CodeAnalysis documentation built on March 1, 2025, 9:54 p.m.