From mcguirebc at gmail.com  Fri Jun  3 23:03:36 2011
From: mcguirebc at gmail.com (mcguirebc)
Date: Fri, 3 Jun 2011 14:03:36 -0700 (PDT)
Subject: [Rd] S4 Slot assignment within function
Message-ID: <1307135016628-3572077.post@n4.nabble.com>

Is there a simple way to assign values to S4 slots from within a function? 

Doing this doesn't work:

> assign_slot<-function(x){

assign("OBJECT at slot",x,envir=parent.env(environment())

}

>assign_slot(x)

All I get from this is a new object with the name OBJECT at slot, the slot
assignment of OBJECT doesn't change.

I have thought about solutions such as eval(parse()) to pull this off, but
would prefer not to ugly up the code.

Thoughts??

I have searched rather thoroughly, but it is possible I overlooked
something. If I did, apologies.

-Brian







--
View this message in context: http://r.789695.n4.nabble.com/S4-Slot-assignment-within-function-tp3572077p3572077.html
Sent from the R devel mailing list archive at Nabble.com.



[Rd] S4 Slot assignment within function
mcguirebc