"날짜"(클래스의 변수 = POSIXlt) 시간을 내 데이터 집합에서 현지화하려고 할 때 오류가 발생합니다. number of items to replace is not a multiple of replacement length
을 : 나는 오류 때문에POSIXlt에 추가하여 다른 시간대의 날짜 변경
# All dates are coded by survey software in EST(not local time)
date <- c("2011-07-26 07:23", "2011-07-29 07:34", "2011-07-29 07:40")
region <-c("USA-EST", "UK", "Singapore")
#Change the times based on time-zone differences
start_time<-strptime(date,"%Y-%m-%d %h:%m")
localtime=as.POSIXlt(start_time)
localtime<-ifelse(region=="UK",start_time+6,start_time)
localtime<-ifelse(region=="Singapore",start_time+12,start_time)
#Then, I need to extract the hour and weekday
weekday<-weekdays(localtime)
hour<-factor(localtime)
, 내 "ifelse"
문에 문제가 있어야 다음과 같이 예제 코드입니다. 도와주세요!
당신의'strptime'은'start_time <-strptime (date, "% Y- % m- % d % H : % m : % s")' – Ryogi
여야합니다 - 죄송합니다. 내 데이터를 실제로 반영하도록 수정되었습니다. 나는 * strptime이 문제라고 생각하지 않는다 ... – roody
당신의'date'는 그렇게 형식화되지 않았다. 'start_time'은'NA NA NA'입니다. '% m/% d/% Y % H : % M' 대신에'% Y- % m- % d % H : % M'과 같은 형식을 사용하십시오. – GSee