Re: [R] Coarsening the Resolution of a Dataset

From: Steve Murray <smurray444_at_hotmail.com>
Date: Thu, 31 Jul 2008 20:52:49 +0000

Please find below my command inputs, subsequent outputs and errors that I've been receiving.

> crops <- read.table("crop2000AD.asc", colClasses = "numeric", na="-9999")
> str(crops[1:10])

'data.frame': 2160 obs. of 10 variables:

 $ V1 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V2 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V3 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V4 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V5 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V6 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V7 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V8 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V9 : num  NA NA NA NA NA NA NA NA NA NA ...
 $ V10: num  NA NA NA NA NA NA NA NA NA NA ...

Don't worry about all the NAs - this is because there is no data available at the poles of the Earth (at the top and bottom of the dataset).

> min.5 <- 5/60
> dim(crops)
[1] 2160 4320
> n <- 2160*4320

> memory.limit()

[1] 382.9844
> crops <- cbind(interval=seq(0, by=min.5, length=n), value=runif(n))
Error: cannot allocate vector of size 142.4 Mb In addition: Warning messages:
1: In cbind(interval = seq(0, by = min.5, length = n), value = runif(n)) :   Reached total allocation of 382Mb: see help(memory.size) 2: In cbind(interval = seq(0, by = min.5, length = n), value = runif(n)) :   Reached total allocation of 382Mb: see help(memory.size) 3: In cbind(interval = seq(0, by = min.5, length = n), value = runif(n)) :   Reached total allocation of 382Mb: see help(memory.size) 4: In cbind(interval = seq(0, by = min.5, length = n), value = runif(n)) :   Reached total allocation of 382Mb: see help(memory.size)

But seems to run when 'value = runif(n)' is excluded....

> crops <- cbind(interval=seq(0, by=min.5, length=n))
> head(crops)

       interval

[1,] 0.00000000
[2,] 0.08333333
[3,] 0.16666667
[4,] 0.25000000
[5,] 0.33333333
[6,] 0.41666667

> str(crops[1:10])

 num [1:10] 0.0000 0.0833 0.1667 0.2500 0.3333 ...

> breaks <- c(seq(min(crops[,'interval']), max(crops[, 'interval']), by=0.5), Inf)
> head(breaks)

[1] 0.0 0.5 1.0 1.5 2.0 2.5
> str(breaks)

 num [1:1555201] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 ...

> myCuts <- cut(crops[, 'interval'], breaks, include.lowest=TRUE)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)? In addition: Warning messages:
1: In formatC(breaks, digits = dig, width = 1) :   Reached total allocation of 382Mb: see help(memory.size) 2: In formatC(breaks, digits = dig, width = 1) :   Reached total allocation of 382Mb: see help(memory.size)
>

This is as far as I've got because of the above errors I encounter. Any pointers and advice, or if I'm doing something obviously wrong, then please let me know.

Thanks again for your help.

Steve



100ís of Nikon cameras to be won with Live Search

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 Thu 31 Jul 2008 - 20:58:08 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 Fri 01 Aug 2008 - 03:33:10 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