最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - Warning in mutate() when removing timezone from date column: "unknown timezone 'EEST'" - S

programmeradmin4浏览0评论

I'm working with a dataset in R, and I'm using mutate() to clean up date values by removing the time zone abbreviation EET or EEST. However, when I try to convert the cleaned date from its original character class to a POSIXct format, I get the following warning:

There was 1 warning in mutate(). ℹ In argument: date = str_remove(date, "EET |EEST "). Caused by warning in as.POSIXlt.POSIXct(): ! unknown timezone 'EEST'

Here's the code I am using:

df <- df |> 
  mutate(
    date = str_remove(date, "EET |EEST "),  # Removing the timezone
    date = parse_date_time(date, orders = "a b d H:M:S Y")  # Parsing the date
  )

Problem: I am removing the EET and EEST time zones from the date column using str_remove(). After removing the time zone, I try to convert the date column to a POSIXct format. The warning suggests that EEST is still causing an issue.

What I've Tried: I've tried adjusting the str_remove() to make sure the spaces are correctly handled ("EET |EEST "). I validated that EEST is correctly removed with any(grepl("EEST", sales_beef$date)), which returns FALSE. I also tried using as.POSIXct() with a specific tz = "UTC", but the warning still appears. Expected Behavior: I expect the date column to be successfully parsed without any warnings related to time zones.

Question: What is causing this warning about the unknown timezone EEST, and how can I avoid this issue? Should I remove the time zone differently or handle the conversion in a different way?

Date format: "Tue Aug 22 14:50:15 EEST 2017" or "Wed Aug 23 14:50:15 EET 2018". Note that the timezones are either EET or EEST.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论