I'm trying to convert a record into a date and time format using the strptime
function. However, I'm not sure why I'm getting the error:
number of items to replace is not a multiple of replacement length.
I tried to check the length of the record using the length
function but both have the same length.
data <- DT
head(data[6])
# column
# 1 2014-12-22 23:53:48
# 2 2014-12-22 23:20:34
# 3 2014-12-22 23:20:30
# 4 2014-12-22 23:20:16
# 5 2014-12-22 23:20:07
# 6 2014-12-22 23:05:49
data[,6] <- as.character(data[,6])
temp_file <- matrix(0,nrow=nrow(data))
temp_file[1] <- strptime(data[1, 6],"%F %T")
# Warning message:
# In temp_file[1] <- strptime(data[1, 6], "%F %T") :
# number of items to replace is not a multiple of replacement length
length(temp_file[1])
# [1] 1
length(data[1,6])
# [1] 1
length(strptime(data[1, 6], "%F %T") )
# [1] 1
Any help is greatly appreciated.
Thanks!