[R] line plot through NA

2006-10-02 Thread rggefrm
Dear R-help list,

I hope I did not miss something obvious, because my question seems very 
simple, but I couln't figure out how to do it.

If I have the following data:
Day-c(1,2,3,4,5,6,7)
V-c(5,NA,10,30,45,NA,10)
than the line in plot

plot(V~Day, type=b)

will start with the 3rd value and stop stop at the 5th value because all NA 
are omitted. Is there now a parameter which can be added to the plot 
function so the line will start with with the first value and skip the NA 
values and can this than applied to xyplots.

Many thanks

__
R-help@stat.math.ethz.ch 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.


Re: [R] line plot through NA

2006-10-02 Thread David Barron
I assume you mean that you want the first point to be connected by a
straight line to the third, etc. because fisrt and sixth points are
shown on the plot.  If so, you can use the approx function:


plot(approx(Day,V,n=length(Day)), type=l)
points(Day,V)

On 02 Oct 2006 15:31:59 +0100, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Dear R-help list,

 I hope I did not miss something obvious, because my question seems very
 simple, but I couln't figure out how to do it.

 If I have the following data:
 Day-c(1,2,3,4,5,6,7)
 V-c(5,NA,10,30,45,NA,10)
 than the line in plot

 plot(V~Day, type=b)

 will start with the 3rd value and stop stop at the 5th value because all NA
 are omitted. Is there now a parameter which can be added to the plot
 function so the line will start with with the first value and skip the NA
 values and can this than applied to xyplots.

 Many thanks

 __
 R-help@stat.math.ethz.ch 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.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@stat.math.ethz.ch 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.


Re: [R] line plot through NA

2006-10-02 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

 Dear R-help list,
 
 I hope I did not miss something obvious, because my question seems very 
 simple, but I couln't figure out how to do it.
 
 If I have the following data:
 Day-c(1,2,3,4,5,6,7)
 V-c(5,NA,10,30,45,NA,10)
 than the line in plot
 
 plot(V~Day, type=b)
 
 will start with the 3rd value and stop stop at the 5th value because all NA 
 are omitted. Is there now a parameter which can be added to the plot 
 function so the line will start with with the first value and skip the NA 
 values and can this than applied to xyplots.

AFAIK, this is not controlable via options or graphics parameters. So
the way forward would be to remove the points with missing data.
Here's one way:

plot(V~Day, type=b, data=na.omit(data.frame(V,Day)))

and another:

plot(V~Day, type=b, subset=complete.cases(V,Day))

and another (messes up axis labels, though)

s - complete.cases(V,Day)
plot(Day[s], V[s], type=b)



-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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.


Re: [R] line plot through NA

2006-10-02 Thread Doran, Harold
Do you mean something like this:

 plot(approx(Day,V), type='l') 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 [EMAIL PROTECTED]
 Sent: Monday, October 02, 2006 10:32 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] line plot through NA
 
 Dear R-help list,
 
 I hope I did not miss something obvious, because my question 
 seems very simple, but I couln't figure out how to do it.
 
 If I have the following data:
 Day-c(1,2,3,4,5,6,7)
 V-c(5,NA,10,30,45,NA,10)
 than the line in plot
 
 plot(V~Day, type=b)
 
 will start with the 3rd value and stop stop at the 5th value 
 because all NA are omitted. Is there now a parameter which 
 can be added to the plot function so the line will start with 
 with the first value and skip the NA values and can this than 
 applied to xyplots.
 
 Many thanks
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.