[R] size and coding error in plot ?

hadley wickham h.wickham at gmail.com
Fri Jul 18 04:35:52 CEST 2008


On Fri, Jul 18, 2008 at 9:44 AM,  <shetumi at aim.com> wrote:
> Hello R users:
>
> I was trying to draw a boxplot?using 2 variables (rain and wind). Both of them has length 25056. So dummy is a matrix with dimension 2 x 25056. First I tried to draw a full boxplot using the following code?and gave an error
>
>> boxplot(dummy$Rain~dummy$Wind)
>
> Error: cannot allocate vector of size 2.8 Gb
> In addition: Warning messages:
> 1: In rep.int(boxwex, n) :
> ? Reached total allocation of 1535Mb: see help(memory.size)
> 2: In rep.int(boxwex, n) :
> ? Reached total allocation of 1535Mb: see help(memory.size)
> 3: In rep.int(boxwex, n) :
> ? Reached total allocation of 1535Mb: see help(memory.size)
> 4: In rep.int(boxwex, n) :
> ? Reached total allocation of 1535Mb: see help(memory.size)
>
> and?thereafter I tried to draw boxplots at regular intervals (that means ) and that didnt work either
>
>> boxplot(dummy$Rain~cut(dummy$Wind,(1:25)*1000), data=dummy)
>
> Error in plot.window(xlim = xlim, ylim = ylim, log = log, yaxs = pars$yaxs) :
> ? need finite 'ylim' values
> In addition: Warning messages:
> 1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
> 2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
> 3: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
> 4: In min(x) : no non-missing arguments to min; returning Inf
> 5: In max(x) : no non-missing arguments to max; returning -Inf
>
> Also I used
>
> ?boxplot(dummy$Rain~cut(dummy$Wind, breaks=seq(from=1,to=25000,by=1000)), data=dummy)
>
> and that showing only sigle boxplot at far left corner.
>
>
> What would be the right ting to do ?

It's hard to check without your data, but the following should work in ggplot2:

install.packages("ggplot2")
library(ggplot2)

# draws a single boxplot
qplot(Rain, Wind, data=dummy, geom="boxplot")
# draws multiple boxplots
qplot(Rain, Wind, data=dummy, geom="boxplot", group = cut(Wind, (1:25)*1000))

Another approach would be to use quantile regression:

qplot(Rain, Wind, data=dummy, geom=c("point", "quantile"))
qplot(Rain, Wind, data=dummy, geom=c("point", "quantile"), formula = y
~ ns(x, 10))

but getting the parametric form (formula) correct may be tricky.

Hadley



-- 
http://had.co.nz/



More information about the R-help mailing list