> Is this what you want?
>
> j <-
> c
> ("2008
> -11
> -14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
> k <- c(83,60,61,87,89,90)
> myplot <- data.frame(j,k)
> qplot(j,k,data=myplot)
This is what I want. Your code above works for me, but I don't know
why it doesn't work with my data (which I pull from an SQL query but
not assemble into a data frame for qplot).
h.wi...@gmail.com said:
> There's a small bug in the labelling algorithm that crops up with
> certain date ranges. You can work around it by explicitly specifying
> the major, minor and format arguments to scale_x_datetime:
>
> ... + scale_x_datetime(major = "2 days", minor = "1 day", format =
> "%d/%m")
This is interesting. It did not solve my problem, though.
Thanks for both of your help! I'll have to dig deeper.
-- Christian
> Is this what you want?
>
> j <-
> c
> ("2008
> -11
> -14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
> j
> k <- c(83,60,61,87,89,90)
> k
> myplot <- data.frame(j,k)
> myplot
> qplot(j,k,data=myplot)
> qplot(j,k,data=myplot,geom="bar")
Actually, this is not what I want because your j does not contain
dates but strings. If you convert j into dates, the problem will show
up again:
> j <-
c
("2008
-11
-14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
> k <- c(83,60,61,87,89,90)
>
> j <- as.POSIXlt(j)
> qplot(j,k)
Error in if (length(range) == 1 || diff(range) == 0) { :
missing value where TRUE/FALSE needed
-- Christian
If you could send a small sample of your dataset (e.g. with dput) I
could look into it in more detail.
Regards,
Hadley
# Or this with your actual data
x <- "IDdate value
2009-02-11 83
2009-02-12 60
2009-02-13 61
2009-02-14 87
2009-02-15 89
2009-02-16 90"
myplot <- read.table(textConnection(x),header=TRUE)
myplot
#myplot$IDdate <- as.Date(myplot$IDdate,"%m/%d/%Y")
qplot(IDdate,value,data=myplot)
--- On Wed, 2/11/09, Christian Lindig <lin...@gmail.com> wrote:
> From: Christian Lindig <lin...@gmail.com>
> Subject: Re: simple time series: plot works, qplot gives error
> To: mazatla...@yahoo.com
> Cc: "ggplot2" <ggp...@googlegroups.com>
> Date: Wednesday, February 11, 2009, 12:44 PM
> On Feb 11, 2009, at 8:24 PM, Felipe Carrillo wrote:
>
> > Is this what you want?
> >
> > j <-
> c("2008-11-14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
> > j
> > k <- c(83,60,61,87,89,90)
> > k
> > myplot <- data.frame(j,k)
> > myplot
> > qplot(j,k,data=myplot)
> > qplot(j,k,data=myplot,geom="bar")
>
> Actually, this is not what I want because your j does not
> contain dates but strings. If you convert j into dates, the
> problem will show up again:
>
> > j <-
> c("2008-11-14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
library(ggplot2)
j <-
c
("2008
-11
-14","2008-10-24","2008-09-27","2008-09-26","2008-09-19","2008-09-10")
k <- c(83,60,61,87,89,90)
j <- as.POSIXct(j)
p <- qplot(j,k)
print(p)
-- Christian