On 10.09.2011 17:08, André Rossi wrote:
Hi everybody!

I'm creating an object of a S4 class that has two slots: ListExamples, which
is a list, and idx, which is an integer (as the code below).

Then, I read a data.frame file with 10000 (ten thousands) of lines and 10
columns, do some pre-processing and, basically, I store each line as an
element of a list in the slot ListExamples of the S4 object. However, many
operations after this take a considerable time.

Can anyone explain me why dois it happen? Is it possible to speed up an
script that deals with a big number of data (it might be data.frame or
list)?

0. This sounds inefficient even when not using S4 classes. You may want to reconsider how to solve your problem in another way.

1. A first step for speedup would be not to use S4 objects.

2. If you really want to use some S4 object to store the stuff, try to assign to a list (that is not wrapped within an S4 class) first and then assign the whole list into your Buffer object.

Best,
Uwe Ligges



Thank you,

André Rossi

setClass("Buffer",
     representation=representation(
         Listexamples = "list",
         idx = "integer"
     )
)

        [[alternative HTML version deleted]]




______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to