I'm sure this is a really simple problem, but I've spent hours digging and I
keep running into roadblocks.
I'm trying to get a simple chart with three time series. Similar to the
attached example
http://www.nabble.com/file/p25398419/Excel%2Bchart%2Bexample.pdf
Excel+chart+example.pdf , something that was quite easy to do in Excel,
except that I need a log y-axis: something that R can do and Excel can't.
The data is in the attached CSV file
http://www.nabble.com/file/p25398419/test%2Bchart%2Bdata.csv
test+chart+data.csv . I can read it in OK, and create separate charts:
testdata<- read.table("C:\\Files\\test chart data.csv", head = T, sep =
",",na.strings = "na")
test_date = as.Date(testdata$Date,"%d-%m-%y")
test_data_model = testdata$Model
test_date_baseA = testdata$BaseDataA
test_date_baseB = testdata$BaseDataB
plot(test_date, test_data_model,type='l',log="y")
plot(test_date, test_data_baseA,type='l',log="y")
plot(test_date, test_data_baseB,type='l',log="y")
grid()
(Clearly at this point, each chart over-writes the previous one.)
Next I try to get them onto a single chart, sharing the same y-axis. I'm
sure I haven't done this very elegantly, but here goes:
frame_model = data.frame(a=test_date,b=test_data_model)
frame_A = data.frame(a=test_date,b=test_data_baseA)
frame_B = data.frame(a=test_date,b=test_data_baseB)
ts_model = ts(frame_model$b)
ts_a = ts(frame_A$b)
ts_b = ts(frame_B$b)
ts.plot(ts_model,ts_a,ts_b,col=c("blue","red","green"),log="y")
The problem is that I no longer have the date along the y-axis. How can I
get that back?
Finally, when I plot the separate time series, the grid() function geneates
a grid where the vertical lines are not lined up with the year tick marks.
I interpreted the topic help as saying that by default they would match the
tick marks. How can I achieve that?
Thanks for any suggestions,
Guy Green