[R] mplot :how to deal with missing data

Jim Lemon bitwrit at ozemail.com.au
Fri Jun 3 00:42:11 CEST 2005


NATALIA F TCHETCHERINA wrote:
> Hello all,
> I have  data:
> 
>            Genes   time rep vart dye         y trt
> 130911   sa1-d07 030min   1  col   g  9.636244   o
> 145771   sa1-d07 030min   1  col   r  8.107577   c
> 93335    sa1-d07 030min   1  ler   g  7.409566   o
> 94821    sa1-d07 030min   1  ler   r  5.107160   c
> 10119101 sa1-d07 030min   2  col   g  8.336862   o
> 11605101 sa1-d07 030min   2  col   r  7.824530   c
> 725313   sa1-d07 030min   2  ler   g  8.249347   o
> 740171   sa1-d07 030min   2  ler   r  7.565084   c
> 1160522  sa1-d07 030min   3  col   g        NA   c
> 1011922  sa1-d07 030min   3  col   r        NA   o
> 562232   sa1-d07 030min   3  ler   g  9.974227   c
> 547362   sa1-d07 030min   3  ler   r 10.341149   o
> ..................................................
> ..................................................
> ..................................................
> 
> I would like to get graphs means for two-way factor combinations
> I used Rlab package:
> 
>>mplot(data$y[which(data$Genes==sa1-d07)],
> 
> data$time[which(data$Genes==sa1-d07)], data$trt[which(data$Genes==sa1-d07)])
>
> However, I have the following error message:
> 
> plot window will lay out plots in a 3 by 1 matrix 
> Error in plot.window(xlim, ylim, log, asp, ...) : 
>         need finite 'ylim' values
> In addition: Warning messages:
> 1: no finite arguments to min; returning Inf 
> 2: no finite arguments to max; returning -Inf 
> 
> I think this is because of some y='NA'.
> My question is: how I can deal with this problem?

Hi Natalia,

Your problem is that the character variable "genes" should be enclosed 
in quotes:

mplot(data$y[which(data$Genes=="sa1-d07")],
   data$time[which(data$Genes=="sa1-d07")],
   data$trt[which(data$Genes=="sa1-d07")])

or a bit more neatly:

which.genes<-data$Genes=="sa1-d07"
mplot(data$y[which.genes],data$time[which.genes],data$trt[which.genes])

Without the quotes, the interpreter reads the value as sa1 - d07, and 
since it cannot find an object named sa1, returns no values. Also, 
"data" is not an ideal name for your data frame.

Jim




More information about the R-help mailing list