quot;]] <- 2012:2013 ; str(x) }
atomic [1:1] 1
- attr(*, "attrName")= int [1:2] 2012 2013
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
From: Murat Tasan [mailto:mmu...@gmail.com]
Sent: Friday, May 10, 2013 10:56 AM
To: William Dunlap
Cc: r-help@r-project.org
Subject:
atomic [1:1] 1
- attr(*, "attrName")= int [1:2] 2012 2013
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
From: Murat Tasan [mailto:mmu...@gmail.com]
Sent: Friday, May 10, 2013 10:56 AM
To: William Dunlap
Cc: r-help@r-project.org
Subject: Re: [R] attr vs attributes
sure, here&
Sent: Friday, May 10, 2013 10:56 AM
To: William Dunlap
Cc: r-help@r-project.org
Subject: Re: [R] attr vs attributes
sure, here's a series of commands/outputs (using R 3.0.0):
> x <- letters[1:4]
> y <- "foo"
> attributes(x)
NULL
> attributes(x)[[y]] <- &q
lt;- "another attribute value"
> > my_obj
> [1] 37 38 39 40 41
> attr(,"myAttr")
> [1] MMXII MMXIII
> attr(,"anotherAttrName")
> [1] "another attribute value"
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Murat Tasan
> Sent: Friday, May 10, 2013 8:16 AM
> To: Duncan Murdoch
> Cc: r-help@r-project.org
> Subject: Re: [R] attr vs attributes
>
> thanks, both.
>
> the only real difference between the two app
thanks, both.
the only real difference between the two approaches that i can see is when
assigning _new_ attributes to an object where the attribute name is itself
variable.
something like this:
> attributes(my_obj)[[my_attr_name]] <- my_attr_value
...fails when my_obj doesn't already have an at
On 10/05/2013 10:50 AM, Rui Barradas wrote:
Hello,
There's at least one example where only the form attr(x, "foo") <- "bar"
would work, not the other form. If you want to set attributes
programatically, use the first form, like in the function below. Note
that the example is artificial.
setAtt
Hello,
There's at least one example where only the form attr(x, "foo") <- "bar"
would work, not the other form. If you want to set attributes
programatically, use the first form, like in the function below. Note
that the example is artificial.
setAttr <- function(x, attrib, value){
hi all -- i looked through the R Language Definition document, but couldn't
find any particular warning or example that would clarify the best use of
attribute setting for R objects.
let x be some R object, and i'd like to add attribute "foo" with value
"bar".
case 1:
> attr(x, "foo") <- "bar"
c
9 matches
Mail list logo