简体   繁体   中英

R- Plotly plot dates are out of order

I am making a plotly plot with this data from 538 . The dates are organized but when I produce a plot (dates as x-axis), it starts with October, then November, then July, and then it's finally in order.

This is all I am doing for code right now.

plot_ly(weather, x = ~date, y = ~actual_min_temp)

Before plotting, make sure your date data is converted to a date class. This error can happen when the date data is a character class instead, for example. To convert data to a date class, you can try using one of these:

weather <- as.Date(weather$date)

#or

weather <- as.POSIXct(weather$date)

Then try plotting again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM