Re: [R] plotting lines with missing data for x values

2009-01-30 Thread Duncan Murdoch

Gareth Campbell wrote:

I have some data (REE plots - geochemistry) where I have values 1:14 for the
x axis, but have no data for some x values.  Here for example, let's say
that I don't have data for x=2,5,8.

So

x-1:14
y-c(4, NA, 5, 9, NA, 3.4, 8, NA, 19, 22, 12, 14, 15.3, 15)

if I plot the data

plot(x,y)

and then I want to join with lines

lines(x,y)

How do I get it so the points join across the missing x-values?  So the line
joins, for example, point 1,4 with point 3,5  (i.e across point 2,NA)?
  
By convention, NA's say to break the lines, so remove the NA's. 


okay - !is.na(x)  !is.na(y)
lines(x[okay], y[okay])

Duncan Murdoch

Thanks in advance.


Gareth Campbell
PhD Candidate
The University of Auckland

P+649 815 3670
M+6421 256 3511
E   gareth.campb...@esr.cri.nz
gcam...@gmail.com

[[alternative HTML version deleted]]

__
R-help@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.



__
R-help@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.


[R] plotting lines with missing data for x values

2009-01-29 Thread Gareth Campbell
I have some data (REE plots - geochemistry) where I have values 1:14 for the
x axis, but have no data for some x values.  Here for example, let's say
that I don't have data for x=2,5,8.

So

x-1:14
y-c(4, NA, 5, 9, NA, 3.4, 8, NA, 19, 22, 12, 14, 15.3, 15)

if I plot the data

plot(x,y)

and then I want to join with lines

lines(x,y)

How do I get it so the points join across the missing x-values?  So the line
joins, for example, point 1,4 with point 3,5  (i.e across point 2,NA)?

Thanks in advance.


Gareth Campbell
PhD Candidate
The University of Auckland

P+649 815 3670
M+6421 256 3511
E   gareth.campb...@esr.cri.nz
gcam...@gmail.com

[[alternative HTML version deleted]]

__
R-help@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.