0
Unix Timeの値を持つTIMESTAMP列のテーブルがあります。夜、朝、昼前、午後、夕暮れ、夕方など、それを日の間隔に変換する必要があります。UnixTimeを昼間(午前、夕方、夜など)に変換するR
data$TIMESTAMP[1]
[1] 1372636858
time <- anytime(1372636858)
> time
[1] "2013-07-01 01:00:58 WEST"
私がやっている:
cut(time, breaks= as.POSIXct(paste("2001-01-01",c("00:00:00", "06:00:00", "09:00:00","12:00:00","15:00:00","18:00:00", "20:00:00")),format="%Y-%m-%d %H:%M:%S", tz ="Portugal"),labels=c('night','morning','before_afternoon','afternoon','twilight','evening'))
を出力は、次のとおりです。
[1] <NA>
Levels: night morning before_afternoon afternoon twilight evening
私が間違っているのか?
日付が異なるため(2013-07-01および2001-01-01)、これは機能しません。おそらく、time要素を取り除くだけでよいでしょう。 –
私は 'c '(' night '、' morning '、' before_afternoon '、' afternoon '、' twilight '、' evening ')[findInterval(as.POSIXlt(time)$ hour、c(0,6、 9,15,18,20))] ' – nicola
それはこの方法で働いた!!!!まさに私が必要でした。どうもありがとう!!!! – Larisa