format a Date column in a Data Frame

前端 未结 3 1675
情书的邮戳
情书的邮戳 2020-12-14 08:16

I\'ve the following data from a data frame

Name,JoiningDate,AmtPaid
Joe,12/31/09,1000
Amy,10/28/09,100
John,05/06/10,200

The Joining Date i

3条回答
  •  臣服心动
    2020-12-14 08:41

    The data.table package has its IDate class and functionalities similar to lubridate or the zoo package. You could do:

    dt = data.table(
      Name = c('Joe', 'Amy', 'John'),
      JoiningDate = c('12/31/09', '10/28/09', '05/06/10'),
      AmtPaid = c(1000, 100, 200)
    )
    
    require(data.table)
    dt[ , JoiningDate := as.IDate(JoiningDate, '%m/%d/%y') ]
    

提交回复
热议问题