データセットで「date」(class=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"
エラーが発生するため、ステートメントに何か問題があるに違いありません: number of items to replace is not a multiple of replacement length
。助けてください!