0
我有一個data.table days_dt如何通過天計算每週小時data.table R中
days_dt <- data.table(day = c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
它看起來像
days_dt
day
1: Monday
2: Tuesday
3: Wednesday
4: Thursday
5: Friday
6: Saturday
7: Sunday
我還有一個單獨的記錄data.table其中我要和時間的每一天:
> weighted_average_time
mon_from_time mon_to_time tue_from_time tue_to_time wed_from_time wed_to_time thu_from_time
1 7.965174 21.39378 7.965174 21.39378 7.965174 21.39378 7.965174
thu_to_time fri_from_time fri_to_time sat_from_time sat_to_time sun_from_time sun_to_time
1 21.39876 7.965174 21.39876 7.942786 21.35149 9.766915 16.91617
我想找到的日常高度差(在新列)和定時在FI第一個表days_dt。例如週一(21.39378 - 7.965174 = 13.42861)
如何使用data.table做到這一點R中
預期的輸出必須看起來像
days_dt
day time_diff
Monday 13.42861
. .
. .
and so on for all the days
增加的預期輸出有問題 –