[R] Unexpected Gap in simple line plot
Bill.Venables at csiro.au
Bill.Venables at csiro.au
Fri Jan 21 02:39:01 CET 2011
You do have missing values. Setting xlim does not subset the data.
How about
########
link <- "http://processtrends.com/files/RClimate_CTS_latest.csv"
cts <- read.csv(link, header = TRUE)
scts <- subset(cts, !is.na(GISS) & !is.na(cts)) ## remove defectives
plot(GISS ~ yr_frac, scts, type = "l", xlim = c(1982, 1983),
xaxs = "i", yaxs = "i")
points(GISS ~ yr_frac, scts, type = "p", col = "red")
########
?
Bill Venables
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of D Kelly O'Day
Sent: Friday, 21 January 2011 11:12 AM
To: r-help at r-project.org
Subject: [R] Unexpected Gap in simple line plot
I am getting an unexpected gap in a simple plot of monthly data series.
I have created a csv file of monthly climate observations that I store
on-line. When I download the csv file and plot one of the series, I get a
gap even though there is data for the missing point.
Here is a snippet to show the problem.
## Strange plot results
link <- "http://processtrends.com/files/RClimate_CTS_latest.csv"
cts <- read.csv(link, header=T)
## Simple line plot - gap for no reason
plot(cts$yr_frac, cts$GISS, type="l", xlim=c(1982, 1983),xaxs="i",
yaxs="i")
## May, 1982 observation missing
## Add points to plot in red, to see if May shows up
points(cts$yr_frac, cts$GISS, type="p", col="red")
## yes, May shows up in points
## Look at cts data.frame. No obvious problems to me??
small <- subset(cts, cts$yr_frac >1982 & cts$yr_frac <1983)
small[,c(1,3)]
The same problem occurs in the other data vectors (HAD, NOAA, RSS, UAH, etc)
I have not been able to figure why I am getting the gap and how to show a
continuous line through May, 1982 data points.
Any suggestions?
D Kelly O'Day
http://chartsgraphs.worpress.com http://chartsgraphs.wordprss.com
--
View this message in context: http://r.789695.n4.nabble.com/Unexpected-Gap-in-simple-line-plot-tp3228853p3228853.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at 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.
More information about the R-help
mailing list