Thanks for your answer, > Yes, that will create two copies. What is it you want to do with the data? > Do you want the capability of both of them changing the data? What type of > processing are you going to do?
The data should be read only (and all the objects share the same data values). > One way is to store the 'name' of the object in the location and then use > 'get/assign' to reference the data: > > obj1$dist <- 'dist' > obj2$dist <- 'dist' > > my.sum <- sum(get(obj1$data)) > assign(obj1$data, new.values) The problem with this solution is that I would like to use those objects with already existing libraries, and thus I cannot choose how the data is read. To explain better, I look for a way to reference to the data that is transparent to the application. In C this would be done by assigning the pointer to the data structure, for example if dist is a C structure and obj1/2 contain a pointer called dist to that kind of structure, I would do: obj1->dist = &dist; obj2->dist = &dist; and then the rest of the code would not even know if obj1->dist is shared among different objects.... Thanks again, Giampiero > > > __________________________________________________________ > James Holtman "What is the problem you are trying to solve?" > Executive Consultant -- Office of Technology, Convergys > [EMAIL PROTECTED] > +1 (513) 723-2929 > > > > Giampiero Salvi > <[EMAIL PROTECTED] To: [EMAIL PROTECTED] > > cc: > Sent by: Subject: [R] reference to objects > [EMAIL PROTECTED] > ath.ethz.ch > > > 01/16/2004 08:22 > > > > > > > Hi, > is there a way to reference to a data object without copying it? > > For example I have a huge matrix called dist and I want two objects > obj1 and obj2 to have a memeber dist that points to the matrix, but > I don't want, for memory reasons, to copy the matrix twice. > > As far as I understand the following code will generate three copies > of my data: > > dist <- some_code_that_generates_data > obj1$dist <- dist > obj2$dist <- dist > > Thank you! > Giampiero > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > > > > -- > "NOTICE: The information contained in this electronic mail transmission is > intended by Convergys Corporation for the use of the named individual or > entity to which it is directed and may contain information that is > privileged or otherwise confidential. If you have received this electronic > mail transmission in error, please delete it from your system without > copying or forwarding it, and notify the sender of the error by reply email > or by telephone (collect), so that the sender's address records can be > corrected." > > > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
