-1
I need to create a Datetime by joining these two columns with the class Posixct. But when returning the table the Datetime comes with NA.
Edt. Following the suggestion of the friend below only appeared the three initial columns. My table has more columns. I had put here only three to exemplify not to get too big here. (My base sheet has more columns).
Below is a sample of data for reproduction:
Mycbon
Date Time Receiver Transmitter ID Transmitter.Serial Sensor Value
2019-04-29 05:31:33 134321 4844 Ane 1305232 28.7 °C PRN
2019-04-29 08:52:08 134325 4861 Bob 1305233 4.2 m MVW
class(mycbon$Date)
class(mycbon$Time)
mycbon$DateTime <- strptime(paste(mycbon$Date, mycbon$Time), %Y-%m-%d %H:%M:OS")
mycbon$DateTime<-as.character(mycbon$DateTime)
mycbon$DateTime<-as.POSIXct(strptime(as.character(mycbon$DateTime),"%Y-%m-%d %H:%M:%OS"))
str(mycbon)
mycbon[,3:12]->myc
myc <- myc[c("DateTime","Receiver", "Transmitter","ID", "Transmitter.Serial", "Sensor", "Value")]
head(myc)
Please make a reproducible example and a better structured question.
– Alexandre Sanches
What is the class of Date and Time columns? Provide a better example of your data, for example by posting the output of
dput(head(mycbon))
.– Carlos Eduardo Lagosta