Skip to content

support (df$var@attr) <- value #3

@garyfeng

Description

@garyfeng

R allows for Replacement functions (http://adv-r.had.co.nz/Functions.html#replacement-functions, or https://cran.r-project.org/doc/manuals/R-lang.html#Subset-assignment) like levels(var)<-c(...). We can extend the syntax to allow for such attribute assignment. According to https://cran.r-project.org/doc/manuals/R-lang.html#Subset-assignment,

names(x) <- c("a","b")

is equivalent to

`*tmp*` <- x
x <- "names<-"(`*tmp*`, value=c("a","b"))
rm(`*tmp*`)

The proposal is something like ``%@%(x, key, value), or `x%@%key <- value`.

x@key <- val

[update: yes!] should be interpreted as

`@`(x, key) <- val
`@<-`(x, key, value=val)

[update: no!] or if evaluation starts from <- first.

`x@key<-` () <- val

which won't make any sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions