开发者

lattice levelplot only fails under RApache

I'm working on a PHP web app that calls R through curl and RApache. Most things work fine. But one lattice plot throws this error:

RApache Warning/Error!!!Error in uy + c(-1, 1) : non-numeric argument to binary operator

I tried saving the data str开发者_如何转开发uctures that feed into the plot and doing the plot in my local R, but then the plot works just fine. So I can't replicate the error.

These are the loaded libraries when the script runs in RApache:

library(Brew)
library(Cairo)
library(rjson)
library(DBI)
library(RMySQL)
library(reshape)
library(plyr)
library('RColorBrewer')
library(ggplot2)
library(lattice)
library(latticeExtra)
library(hexbin)

Here is a bit of the script:

colgrad.pal<-colorRampPalette(brewer.pal(11,'Spectral'), interpolate='spline')

//problem plot
dists.med.lplot<-levelplot(value~starttime+groupname|dists, data=MDist.median,
  col.regions=rev(colgrad.pal(200)),colorkey=list(col=rev(colgrad.pal(200))),
  xlab='Time(s)',ylab='Treatment',
  main='Level Plot of Median Distance',
  layout=c(1,3))

And here is a link to a datafile. I read it in like this: //link appears untrustworthy, so removed

Data looks like this:

'data.frame':   2880 obs. of  6 variables:
 $ groupname: Factor w/ 8 levels "rowA","rowB",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ fCycle   : Factor w/ 6 levels "Cycle 1","Cycle 2",..: 6 6 6 6 6 6 6 6 6 6 ...
 $ fPhase   : Factor w/ 2 levels "Dark","Light": 1 1 1 1 1 1 1 1 1 1 ...
 $ starttime: int  0 60 120 180 240 300 360 420 480 540 ...
 $ dists    : Factor w/ 3 levels "inadist","lardist",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ value    : num  47.5 64 78.3 39.2 53.7 ...

Any ideas on what the problem is or how to better troubleshoot this?

ETA version/platform info

        [platform] => sparc-sun-solaris2.10
        [arch] => sparc
        [os] => solaris2.10
        [system] => sparc, solaris2.10
        [status] => 
        [major] => 2
        [minor] => 10.1
        [year] => 2009
        [month] => 12
        [day] => 14
        [svn rev] => 50720
        [language] => R
        [version.string] => R version 2.10.1 (2009-12-14)


The error smells of an issue with your data. I would try the following:

  • before the actual call to plot() et al, save all your (relevant) data via save(x, y, z, ..., file="/tmp/dbg.RData")
  • then load all the relevant data from the saved file in a 'normal' R session and inspect and compare
  • this should allow you to pinpoint a data issue that you may then be able to circumvent with more sanity checks etc to prevent your actual code from falling over.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜