Briefly, the steps to get the data.frame are:
1. Read a image as a data.frame with readGDAL - this is the first loop.
2. Dataframe is classified with a predict(lda())
3. It's back converted to a SPDF called pixID
4. Pixels (regions) of a specific class of the SPDF pixID is dissolved into
single regions code with adehabitats labcon() function
5. Coordinates of each ID created with labcon() is compiled to the final
data.frame along with image name in a loop like this

ctd.amarelo=data.frame()
    for(z in as.numeric(unique(pixID@data$ID)))
              #! Combine coordinates into a dataframe at each loop
    {
      centroid = data.frame()
      centroid = pixID@coords[pixID@data$ID==z,]
      centroid = if(class(centroid)=="numeric"){
data.frame(lapply(pixID@coords[pixID@data$ID==z,],mean))}
        else{as.data.frame(lapply(as.data.frame(pixID@coords[pixID@data
$ID==z,]),mean))}
      centroid$ID = z
      centroid$img = testelist[i]
      centroid$data.file = quant.sinais[i,1]
      ctd.amarelo=rbind(ctd.amarelo,centroid[centroid$ID!=0,])

    }

ctd.amarelo is the resulting data.frame.

This loop is repeated into a loop that will read each image, following the 5
steps above.

ctd.amarelo data.frame will necessarily be very large since I'll have
thousands of images to classify.

I never used a lapply to replace a for() and now, without think about it, I
don't even know this could replace it

I hope it's clear enough.




2009/8/2 jim holtman <jholtman@gmail.com>

> How are you creating the dataframes?  You did not provide an example
> of the code.  Can you use 'lapply' instead of a 'for' loop and then
> use 'do.call(rbind, lappy_result)' to create your dataframe?  Adding
> each time through the loop can get resource consuming if the
> dataframes are large, but you gave no idea of what you are trying to
> process or how large it is.
>
> On Sun, Aug 2, 2009 at 4:59 PM, Paulo Google<pauloeducardoso@gmail.com>
> wrote:
> > I'm not sure if there are better methods to create objects such as
> > dataframes with other than rbind function.
> > II usually combine a data.frames created at each loop with a rbind(),
> > specially when I don't know the dimension of the data.frame that will be
> > created.
> >
> > Binding the new to an existing data.frame seems to be the easiest way to
> > build an object that assemble data in a loop.
> >
> > Nevertheless, rbind seems to be much slower than filling rows of a
> previous
> > created object but I don't know how this could be done in all situations,
> > specially when the number of rows of the created object may vary at each
> > loop.
> >
> > Any idea of alternatives to rbind?
> >
> > _______________
> > Paulo E. Cardoso
> >
> >        [[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.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>



-- 
_______________
Paulo E. Cardoso

	[[alternative HTML version deleted]]


