Hi:
In addition to Brandon's comments, there are several things missing
that could be important, including the version of R you are running
and the version of ggplot2. You can supply this with the output from
sessionInfo().
On Wed, May 16, 2012 at 11:54 AM, abc123s <
peter...@gmail.com> wrote:
> I get the error
> Error: Discrete value supplied to continuous scale
> when I run the following code:
> require(reshape)
> require(ggplot2)
> a <- read.csv("test.csv")
> a$Date <- as.POSIXct(strptime( as.character( a$Date) , '%m/%d/%Y %H:
> %M'))
> a <- a[c(-7,-8)]
> a$sum <- rowSums(a[2:6])
> a <- melt (a, id = 'Date' , variable_name = 'Machines')
> p = ggplot(a, aes(Date,value)) + geom_line(aes(colour = Machines)) +
> scale_y_continuous('Load') + scale_x_continuous()
What is the class of Date in the melted data frame a? If it is a
POSIXct or Date object, you should be able to use scale_x_date() or
scale_x_datetime(), but the arguments differ in versions 0.8.9 and
0.9.x. That's why the sessionInfo() matters. For version 0.9.x, the
ggplot2 transition guide may be helpful: see
http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf,
particularly section 7.1.
HTH,
Dennis
>
> The test.csv file begins as a csv file where the first column
> specifies the date and time of the observation, and then each of the
> next columns specifies a machine that the observation was made from.
> I'm trying to graph these observations in chronological order, all on
> one graph (as well as the sum of all the observations on each date).
>
> I want to change the scale of the markings on the x-axis, but
> regardless of whether or not I use scale_x_continuous() or
> scale_x_discrete(), I get the same error. Does anyone know why this is
> happening, or if there is a better way to do what I want?
>