Re: [Rd] S4 Slot assignment within function

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Sat, 04 Jun 2011 06:21:28 -0700

On 06/03/2011 02:03 PM, mcguirebc wrote:
> 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.

Maybe you're looking for ?ReferenceClasses rather then S4 classes?

Martin

>
> -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.
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 04 Jun 2011 - 13:30:40 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 04 Jun 2011 - 14:40:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive