0
votes

This is my data frame structure

str(data10180619_Draft_input_temp) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 347 obs. of 2 variables: $ DATE : Date, format: "2019-03-01" "2019-03-04" "2019-03-04" "2019-03-05" ... $ ENTRY_TIME: POSIXlt, format: "2019-03-01 09:30:08" "2019-03-04 09:30:09" "2019-03-04 09:37:06" "2019-03-05 09:31:14" ...

I'm trying to insert a row into the data frame, I'm able to populate the DATE, but the ENTRY_TIME is giving me errors

data10180619_Draft_input_temp[nrow(data10180619_Draft_input_temp)+1,]<-c("2019-09-29",as.POSIXlt.character("09:30:02",format = '%H:%M:%S',origin="2019-09-29")) Error in as.POSIXlt.numeric(value) : 'origin' must be supplied In addition: Warning message: In [<-.data.frame(*tmp*, nrow(data10180619_Draft_input_temp) + : provided 12 variables to replace 2 variables

I'd like the date portion of the posixlt (ENTRY_TIME) to be the same as the date populated in DATE column

1

1 Answers

0
votes

It would be easier to answer your question with a sample of your data. And make sure to format your code as code. The value passed to origin has to be a date, currently it's a string. Try this:


data10180619_Draft_input_temp[nrow(data10180619_Draft_input_temp)+1,] <-as.POSIXlt.character("09:30:02",
                                                                                             format = '%H:%M:%S',
                                                                                             origin=ymd("2019-09-29"))