R - How can I add an empty POSIXct column to a data.frame / tibble which already exists?
问题 I can initialize a data frame with a POSIXct column with code like this: df <- data.frame(a=numeric(), b=character(), c=as.POSIXct(character())) However, if I try to add an empty POSIXct column to a data.frame or tibble which already exists, the column is transformed to numeric type/class. > df <- tibble("Index"=numeric(10)) > df[,"date"] <- as.POSIXct(character()) > df[,"date"] %>% pull %>% class() [1] "numeric Is there a method to overcome this problem? 回答1: would this work for you (most