[R] plotting big zoo object memory problem

Gabor Grothendieck ggrothendieck at gmail.com
Wed Mar 5 16:16:12 CET 2008


You could try plotting it in pieces to use less RAM.

library(zoo)
library(chron)
z <- zoo(1:10, chron(1:10))

# same as plot(z)
plot(z[1:5], ylim = range(z), xlim = range(time(z)))
lines(z[5:10])

On Wed, Mar 5, 2008 at 10:00 AM, stephen sefick <ssefick at gmail.com> wrote:
> the comma seperated file is 37Mb, and I get the below message:
> it is zoo object read in this way:
>
> # chron
> > library(chron)
> > fmt.chron <- function(x) {
> +    chron(sub(" .*", "", x), gsub(".* (.*)", "\\1:00", x))
> + }
> > z1 <- read.zoo("all.csv", sep = ",", header = TRUE, FUN = fmt.chron)
>
> and then the plot is done with:
>
> > plot(z2[, c(2, 15, 28, 41, 54, 67, 80, 93, 106)], main="SpCond 9/6/06 on", xlab="Date")
>
> and the resulting warning message:
>
> Warning messages:
> 1: In attr(x, "index") <- attr(x, "oclass") <- attr(x, "frequency") <- NULL :
>  Reached total allocation of 502Mb: see help(memory.size)
> 2: In attr(x, "index") <- attr(x, "oclass") <- attr(x, "frequency") <- NULL :
>  Reached total allocation of 502Mb: see help(memory.size)
>
> it still plots the file.  I am currently limited to my computer at
> work with only 504Mb of RAM (windows), and my computer at home with
> 1Gb of RAM (Macintosh).  But I will probably be using my work computer
> for a lot of analysis on this data set (and it will become marginally
> larger).  Will this be a problem?  I am a biologist not a computer
> scientist.
> thanks for the help
>
> --
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                                                -K. Mullis
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list