fork download
  1. # your code goes here
  2.  
  3. library(dplyr)
  4.  
  5. typhoon <- read.csv("C:\\Users\\TOM\\Desktop\\颱風資料\\typhoon.csv")
  6. typhoon <- read.csv("C:\\Users\\chiuyuanwu\\Desktop\\typhoon.csv")
  7. wanted_days <- typhoon %>% filter(Hour %in% c(0, 6, 12, 18)) %>%
  8. group_by(Year, Month, Day) %>% # 我猜測你完整的資料集有不同年月份,這樣寫比較不會出錯
  9. summarise(n = n_distinct(Hour)) %>% filter(n == 4) # 挑選出同一天含有這四個時間點的日期儲存為變數
  10. ## 注意,上述寫法若同天有兩個颱風可能會出錯,建議你建一個颱風的id
  11.  
  12. typhoon_filter <- typhoon %>% filter(Year %in% wanted_days$Year &
  13. Month %in% wanted_days$Month &
  14. Day %in% wanted_days$Day)
  15.  
  16. # 完成
Success #stdin #stdout #stderr 0.66s 50248KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Error in file(file, "rt") : cannot open the connection
Calls: read.csv -> read.table -> file
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:\Users\TOM\Desktop\颱風資料\typhoon.csv': No such file or directory
Execution halted