Displaying 3 results from an estimated 3 matches for "datetime2".
Did you mean:
datetime
2012 May 27
3
Problem with strptime
...011-11-30 04:38:47 GMT"
3rd Qu. Max.
"2012-01-22 09:00:01 GMT" "2012-03-15 13:00:01 GMT"
> min(datetime1)
[1] "2011-08-15 21:00:01 BST"
> data2=read.table("data2.txt",header=T,sep="\t")
> datetime2=strptime(data2$Date, "%a %b %d %H:%M:%S %Y") #example line from
data2 ''Sun Nov 27 13:07:01 2011''
> summary(datetime2)
Min. 1st Qu.
Median Mean
"2011-11-27 01:07:01 GMT" "2012-01-09 20:07:01...
2011 Feb 02
0
Need help subsetting time series data
...quot;, "%m/%d%Y
%H:%M:%S"))
>MR1001$min<-datetime$min
>t1<-subset(MR1001,min==30|min==31|min==32|min==33|min==34)
>datetime<-paste(MR1001$date,MR1001$time)
>datetime<-as.POSIXct(strptime(as.character(datetime), tz="UTC", "%m/%d%Y
%H:%M:%S"))
>datetime2<-datetime[-1]
>datetime2[length(datetime)]<-datetime2[length(datetime)-1]+3600
>datetime3<-datetime2-datetime
>datetime4<-datetime3/60
>datetime5<-as.numeric(datetime4)
>t1$diff<-datetime5
This didn't work either though, because when an unwanted fix occurred af...
2012 Mar 30
1
lubridate:ymd_hm and coercion of class POSIXct. Smooth way to restore the date format.
...ata on date and time.
# install.packages("lubridate")
# library(lubridate)
ymd_hm(x$datetime[!is.na(x$time)])
#Looks OK
# try on the whole data frame:
ymd_hm(x$datetime)
# missing data causes error. Fair enough.
# try to allocate the result to the data frame on rows with complete data
x$datetime2[!is.na(x$time)] <- ymd_hm(x$datetime[!is.na(x$time)])
x
class(ymd_hm(x$datetime[!is.na(x$time)]))
class(x$datetime2)
# POSIXct is coerced to numeric. Fair enough
# try to pre-allocate a vector and convert it to class POSIXct:
x$datetime3 <- NA
class(x$datetime3) <- "POSIXct"
x...