I am working with data, 1st two columns are dates, 3rd column is symbol, and 4th and 5th columns are prices. So, I created a subset of the data as follows:
test.sub<-subset(test,V3=="GOOG",select=c(V1,V4) and then I try to plot a time series chart using the following
as.ts(test.sub) plot(test.sub) well, it gives me a scatter plot - not what I was looking for. so, I tried plot(test.sub[1],test.sub[2]) and now I get the following error:
Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ To make sure the no. of rows were same, I ran nrow(test.sub[1]) and nrow(test.sub[2]) and they both return equal rows, so as a newcomer to R, I am not sure what the fix is.
I also ran plot.ts(test.sub) and that works, but it doesn't show me the dates in the x-axis, which it was doing with plot(test.sub) and which is what I would like to see.
test.sub[1] V1 1107 2011-Aug-24 1206 2011-Aug-25 1307 2011-Aug-26 1408 2011-Aug-29 1510 2011-Aug-30 1613 2011-Aug-31 1718 2011-Sep-01 1823 2011-Sep-02 1929 2011-Sep-06 2035 2011-Sep-07 2143 2011-Sep-08 2251 2011-Sep-09 2359 2011-Sep-13 2470 2011-Sep-14 2581 2011-Sep-15 2692 2011-Sep-16 2785 2011-Sep-19 2869 2011-Sep-20 2965 2011-Sep-21 3062 2011-Sep-22 3160 2011-Sep-23 3258 2011-Sep-26 3356 2011-Sep-27 3455 2011-Sep-28 3555 2011-Sep-29 3655 2011-Sep-30 3755 2011-Oct-03 3856 2011-Oct-04 3957 2011-Oct-05 4059 2011-Oct-06 4164 2011-Oct-07 4269 2011-Oct-10 4374 2011-Oct-11 4479 2011-Oct-12 4584 2011-Oct-13 4689 2011-Oct-14 str(test.sub) 'data.frame': 35 obs. of 2 variables: $ V1:Class 'Date' num [1:35] NA NA NA NA NA NA NA NA NA NA ... $ V4: num 0.475 0.452 0.423 0.418 0.403 ... head(test.sub) V1 V4 1212 <NA> 0.474697 1313 <NA> 0.451907 1414 <NA> 0.423184 1516 <NA> 0.417709 1620 <NA> 0.402966 1725 <NA> 0.414264 Now that this is working, I'd like to add a 3rd variable to plot a 3d chart - any suggestions how I can do that. thx!
plot(test.sub,type="l").plot(test.sub).Error in xy.coordswhen the number of rows in both the columns are the same