user3819981
user3819981

Reputation: 17

Histogram and date position in R

My histogram doesn't look like it's on the correct date when I plot it.

My data looks like this

date        tcol    names
2005-03-31   170    Site 4
2005-03-31   328    Site 5
2005-03-31   40     Site 6

My Code looks like

ggplot(data=allsite, aes(x=date, weight=tcol, colour=names, fill=names))+
geom_histogram(binwidth=20000, position=position_dodge())+
scale_y_continuous(limits=c(0,1000))+
scale_x_datetime(labels = date_format("%d-%m-%y"), 
                 limits = as.POSIXct(c("2005-03-29","2005-04-02")))

It's appearing as thought the data is for the 30th of the 3rd and not the 31st Here's the graph image

Thanks for any help you can give me :)

Upvotes: 1

Views: 101

Answers (1)

timat
timat

Reputation: 1500

you need to specify the time zone in as.POSIXct

limits = as.POSIXct(c("2005-03-29","2005-04-02"), tz="GMT"))

Upvotes: 2

Related Questions