Re: [R] Converting 3 columns of a data frame into a matrix

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 22 Jun 2010 10:53:06 -0400

On Jun 22, 2010, at 4:57 AM, Jeff08 wrote:

>
> Okay, it crosstab seems to work when I clear out a bunch of my
> variables,
> went from 800 mb Vcol to 100 mb
>
> Can anyone explain how memory works in R, because my lack of
> understanding
> with memory was clearly the problem.

Making the assumption that you are on Windows, since you choose not to mention your OS. The Windows FAQ would be the first place to start:

http://cran.r-project.org/bin/windows/base/rw-FAQ.html

In particular:
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021

There also many discussions in the archives. I use this function modified from some other person's code (but have forgotten the author) to determine if I have memory allocation options. You could modify the function to display more than just the largest ten objects:

function() {z <- sapply(ls(envir=globalenv()),

                                 function(x) object.size(get(x)))
                (tmp <- as.matrix(rev(sort(z))[1:10]))}

  .... and then use rm() to delete the extraneous objects

-- 
David.

>
>
> Jeff08 wrote:
>>
>> ##I have also tried the reshape package
>> library(reshape)
>> mm <- melt(df, id=c("date_", "id"))
>> mm1 <- cast(mm, date_~id)
>>
>> aba <- mm1[,-1]
>>
>> final <- as.matrix(aba)
>> colnames(final) <- df$id
>> rownames(final) <- mm1$date_
>> final
>>
>> ##Again it works perfectly here, but when I get to my real dataset,
>> I get
>> a "Cannot allocate vector of size 27.4 MB" error
>>
>> It seems that the main problem is memory size. Is there an
>> efficient way
>> to do this?
>>
>>
snipped what now appears to be tangential material David Winsemius, MD West Hartford, CT ______________________________________________ R-help_at_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.
Received on Tue 22 Jun 2010 - 14:56:40 GMT

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 Tue 22 Jun 2010 - 15:15:34 GMT.

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

list of date sections of archive