I have variable mod
of class unmarkedFitPCount
from package unmarked
and I need to add a new attribute to that class:
mod@new_attr <- 1
I get an error:
‘new_attr’ is not a slot in class “unmarkedFitPCount”
I need to add this new attribute without creating a new derived class, because I need all those functions to work on this object. This is supposed to be just a very lightweight temporary hack. How can I do that?
What about: attributes(mod)$new_attr <- 1
.
The core function attributes
accesses an object's attributes. In this example you create a new attribute new_attr
and assign it the value of 1.
You can then access the newly created attribute via attributes(mod)$new_attr
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With