2015-11-11 5 views
0

J'essaie d'allouer mes données de temps en 15 minutes d'intervalle discret. Cependant, il montre une erreur dans la valeur minimale. Quelqu'un a une idée de cela?R Erreur: Format = NA

Mes données THis

"10-28-15","00:04:13","13-01","1" 
"10-28-15","00:04:16","13-10","1" 
"10-28-15","00:04:30","13-11","1" 
"10-28-15","11:59:44","13-12","1" 
"10-28-15","00:04:48","13-13","1" 
"10-28-15","00:04:50","13-14","1" 
"10-28-15","00:04:57","13-15","0" 
"10-28-15","00:37:57","13-17","0" 
"10-28-15","00:45:04","13-17","0" 
"10-28-15","00:13:04","13-17","0" 

Ceci est mon R Script:

sample<-read.csv("C:\\Users\\Toshiba\\Desktop\\Parkeasy\\Sunway\\parkeasy.csv",header=FALSE,sep=",") 
sample$int<- strptime(paste(sample$V1,sample$V2),format="%m-%d-%y %H:%M:%S") 
min_V2<-trunc(min(strptime("2015-10-28 00:00:01", "%d-%m-%y %H:%M:%S"),"min") 
max_V2<-trunc(min(strptime("2015-10-28 23:59:59", "%d-%m-%y %H:%M:%S")),"min") + 900 
out <- cut(sample$int, breaks = seq(min_V2, max_V2, by = "15 min")) 

indique l'erreur quand je l'exercerai min_V2

min_V2 
POSIXlt[1:1] Format:NA 

et

Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite

Répondre

2

Vos formats de date ne concordent pas.

min_V2<-trunc(min(strptime("2015-10-28 00:00:01", "%d-%m-%y %H:%M:%S"),"min") 
max_V2<-trunc(min(strptime("2015-10-28 23:59:59", "%d-%m-%y %H:%M:%S")),"min") + 900 

Au lieu de %d-%m-%y %H:%M:%S, vous voulez %Y-%m-%d %H:%M:%S pour correspondre à votre chaîne de date.