Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit793580f

Browse files
committed
Prevent start dates earlier than API (1840;fixes#174)
1 parent619eb21 commit793580f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

‎NEWS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#weathercan 0.7.5
22
- Fix province names for stations data frame (#175)
3+
- Don't allow start times earlier than 1840 (earliest API will return;#174)
4+
35
#weathercan 0.7.4
46
- Add`qual` from newly added Flags column to hourly data
57
- Remove vcr

‎R/weather.R‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ weather_dl <- function(station_ids,
189189
}else {
190190
s.start<- as.Date(start)
191191
if(s.start> Sys.Date())s.start<- Sys.Date()
192+
if(s.start< as.Date("1840-01-01"))s.start<- as.Date("1840-01-01")# Earliest date API will return
192193
msg.start<-start
193194
}
194195

@@ -393,14 +394,17 @@ weather_dl <- function(station_ids,
393394
weather_single<-function(date_range,s,interval,encoding) {
394395

395396
w<-dplyr::tibble(date_range=date_range)
396-
w<-dplyr::mutate(w,html=purrr::map(.data$date_range,
397-
~ weather_html(station_id=s,
398-
date=.x,
399-
interval=interval)))
400-
w<-dplyr::mutate(w,data=purrr::map(.data$html,
401-
~ weather_raw(.,
402-
encoding=encoding,
403-
header=TRUE)))
397+
w<-dplyr::mutate(
398+
w,
399+
html=purrr::map(.data$date_range,~ weather_html(station_id=s,
400+
date=.x,
401+
interval=interval)),
402+
data=purrr::map(.data$html,~ weather_raw(.x,
403+
encoding=encoding,
404+
header=TRUE)),
405+
n=purrr::map_int(.data$data,ncol))
406+
407+
w<-dplyr::filter(w,.data$n>1)# Drop requests with no data
404408
w<-dplyr::select(w,"data")
405409

406410
if(utils::packageVersion("tidyr")>"0.8.99") {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp