I have a data frame with two variables. One of them is date (Col1) and the other is numeric population data (sk). I can plot the data like this:
plot(D$sk)
my problem is that (obviously) the plot does not include the dates in the x axis. I have tried to add it by this code:
plot(D$sk, D$Col1, ylim=c(2013-01,2015-05))
But I receive a blank plot and the following error message:
Warning message:
In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
Based on this answer to a similar question I tried using the xaxt=n
argument like this:
with(D, plot(Col1, sk, xaxt="n"))
but it does not work either. I got the following error:
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Can you please help how I could go forward?
EDIT: Col1
is defined by this code:
Col1=seq(as.Date("2013/1/1"), by="1 month", length.out=41).
The sk
variable is some random number between 100.000 and 200.000. I'm sorry, but I'm new to R and am not sure how to reproce that. I have extracted it from 41 excel sheets and since transformed it a couple of times. But basically these are the two variables in the data frame. I hope this helps somewhat.
EDIT2: Sorry, just noticed there is another code which reduced the date variable:
D$Col1=format(D$Col1, format="%Y-%m")