Looping through vector of dates in R drops class info

后端 未结 3 1860
Happy的楠姐
Happy的楠姐 2021-01-23 01:22

Here is my example.

my_df <- data.frame(col_1 = c(1,2), 
col_2 = c(as.Date(\'2018-11-11\'), as.Date(\'2016-01-01\')))
dates_list <- my_df$col_2
for(el in d         


        
3条回答
  •  日久生厌
    2021-01-23 01:53

    You can also use as_date function from lubridate.

    library(lubridate)
    
    for(i in dates_list){
       print(as_date(i))
    }
    
    [1] "2018-11-11"
    [1] "2016-01-01"
    

提交回复
热议问题