[R] Line graphs with NA

Chris Poliquin poliquin at sas.upenn.edu
Sun Dec 28 19:39:30 CET 2008


I have sets of three points provided by subjects that I want to graph  
as lines over a specific range, but the subjects were split into two  
groups and provided different points.  The subjects provided a y-value  
for the given x-value, for example:

Subject:     1      2      3      4      ...   127
"1"            NA    3      2     NA     ...
"2"            4    NA    NA     4
"3"            6    6.5     6     5.5
"4"            7    NA     NA    7
"5"           NA    8     7.5    NA

Using matplot() or xyplot() I can easily get R to plot the lines for  
subjects 1 and 4, but R wont draw lines connecting the points for  
subjects 2 and 3 since there are missing values.  I want R to just  
connect the points for B and C as if the missing values don't matter  
and make it look as if each subject provided 5 points.  What is the  
best way to do this?

- Chris

More information about the R-help mailing list