有没有办法在 R 中将单列从军事时间转换为标准时间?

Is there a way to convert a single column from military time to standard time within R?

我有数据集

                  ID            Date

                  A        2019-12-13 20:19:24
                  A        2019-12-13 20:19:24
                  A        2019-12-13 20:19:24

我想要这个结果,其中小时数转换为标准时间

                  ID            Date

                  A        2019-12-13 8:19:24
                  A        2019-12-13 8:19:24
                  A        2019-12-13 8:19:24


                  I have tried this:

                  library('lubridate)
                  format(strptime(data$Date, format ='%H:%M:%S'), '%I:%M:%S %p')


             I keep getting error: 3: In doTryCatch(return(expr), name, parentenv, handler)                         :
             invalid graphics 

在基础 R 中,您可以使用 %r

 transform(df,Date = format(strptime(Date,"%F %T"),"%F %r"))
      ID                   Date
    1 A  2019-12-13 08:19:24 PM
    2 A  2019-12-13 08:19:24 PM
    3 A  2019-12-13 08:19:24 PM