2

I have a huge database where I extracted only three days to explore the temperature along each hour per day. Data looks like this:

head(agosto123)

     X       date     Hour   temp     HR place placeconse            datetime
1 2266 0001-08-15 00:00:00 27.801 82.797 fundo       8905 0001-08-15 00:00:00
2 2269 0001-08-15 01:00:00 27.949 83.745 fundo       8906 0001-08-15 01:00:00
3 2302 0001-08-15 02:00:00 28.196 84.343 fundo       8907 0001-08-15 02:00:00
4 2317 0001-08-15 03:00:00 28.345 84.375 fundo       8908 0001-08-15 03:00:00
5 2320 0001-08-15 04:00:00 28.444 84.740 fundo       8909 0001-08-15 04:00:00
6 2323 0001-08-15 05:00:00 28.518 84.699 fundo       8910 0001-08-15 05:00:00

....plus other 90 observations

I tried the next option:

agosto123$datetime<-as.POSIXct(agosto123$datetime, format="%d-%m-%Y %H:%M:%S")

tempagosto123<-ggplot(agosto123,
              aes(aes(datetime, temp)))+
geom_point(colour= "blue")+
geom_line(aes(colour = "red"))
temapgosto123

It appears the next error:

Don't know how to automatically pick scale for object of type uneval. Defaulting to continuous. Error: Aesthetics must be either length 1 or the same as the data (96): x

Then, I tried a second option:

tempagosto123<-ggplot(agosto123,
              aes(aes(datetime, temp)))+
geom_point(colour= "blue")+
geom_line(aes(colour = "red"))+
scale_x_datetime(breaks = date_breaks("60 min"))
tempagosto123

And it appears the next error: Error: Aesthetics must be either length 1 or the same as the data (96): x

Could you please, tell me what I am doing wrong? Thanks in advance for your help!

The graph that I get when I removed one aes in this code:

tempagosto123<-ggplot(agosto123(aes(datetime, temp))+ geom_point(colour= "blue")+ geom_line(aes(colour = "red"))+ scale_x_datetime(breaks = date_breaks("60 min")) tempagosto123

enter image description here

Data for each hour is stacked per day and that is wrong. Thanks for all your help!

  • Can you provide a reproducible dataset? Perhaps just one day in August or something? It will make it easier to work out what is wrong. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – william3031 Jun 16 '20 at 22:03
  • What does `str(agosto123)` produce? – william3031 Jun 16 '20 at 22:13
  • 1
    You call the aesthetic specification `aes` twice: `aes(aes(datetime, temp))`. Can you try removing one and see if the error message disappears? – Paul van Oppen Jun 17 '20 at 00:48
  • Thank you! Yes, I made a mistake of writing aes twice. I removed one and I added the graph that I get in my question above. – Aída Otálora-Ardila Jun 20 '20 at 15:17

0 Answers0