Функция даты в R - PullRequest
       11

Функция даты в R

0 голосов
/ 04 августа 2020

Возникли проблемы с запуском date_function на R. Я пробовал несколько разных примеров. Шаги для воспроизведения

Пример 1

 coord_x_date(xlim = c("2020-07-02", "2020-07-09"), ylim = 
  c(5,30)) 
    +

   scale_x_datetime(date_breaks = "2 hours")
   Error: Invalid input: time_trans works with objects of class 
 POSIXct only

Пример 2

coord_x_date(xlim = c("2020-07-02", "2020-07-09"), ylim = c(5,30)) +

scale_x_date(date_minor_breaks = "2 hours")
Error in cut.Date(date, time, right = TRUE, include.lowest = TRUE) :
invalid specification of 'breaks'

Пример 3

  coord_x_date(xlim = c("2020-07-02", "2020-07-09"), ylim = c(5,30)) +
+

    scale_x_datetime(breaks = date_breaks("1 day"), minor_breaks = 
    date_breaks("2 hour"))
      Error: Invalid input: time_trans works with objects of class 
    POSIXct only

scale_x_datetime (xlim = as.POSIXct ( c («2020-07-02», «2020-07-09»))) не работает Есть идеи, что я делаю не так?

1 Ответ

0 голосов
/ 04 августа 2020

Вы можете использовать coord_x_datetime для соответствия scale_x_datetime

  coord_x_datetime(xlim = c(("2020-07-02", "2020-07-09"), ylim = c(5,30)) +
 scale_x_datetime(date_breaks = "1 hours")
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...