From 8f5c6633b95295930056b9708889ab237319b713 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Tue, 5 Sep 2023 17:16:45 +0900 Subject: [PATCH 01/17] [add]cran comments --- .Rbuildignore | 1 + cran-comments.md | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index bf9a967..f741df8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ ^\.github$ ^inst/\.gitignore$ ^inst/real$ +^cran-comments\.md$ diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. From 0af685421f1a27f2de3fd173af9f06415b96a33d Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Tue, 5 Sep 2023 17:17:46 +0900 Subject: [PATCH 02/17] [remove]docker env --- .Rbuildignore | 3 --- Dockerfile | 31 ------------------------------- docker-compose.yml | 13 ------------- 3 files changed, 47 deletions(-) delete mode 100644 Dockerfile delete mode 100644 docker-compose.yml diff --git a/.Rbuildignore b/.Rbuildignore index f741df8..c1ab434 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,8 +1,5 @@ -^\.env$ ^jmastats\.Rproj$ ^\.Rproj\.user$ -^Dockerfile$ -^docker-compose\.yml$ ^data-raw$ ^LICENSE\.md$ ^\.DS_Store$ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 756bf2b..0000000 --- a/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM rocker/geospatial:4.0.2@sha256:bc95d044d7e7289055962cbbd7daf58daf680e8a930ba3bd19d85a90080a7e41 - -ARG GITHUB_PAT - -RUN set -x && \ - echo "GITHUB_PAT=$GITHUB_PAT" >> /usr/local/lib/R/etc/Renviron - -RUN set -x && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - qpdf && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN set -x && \ - install2.r --error --ncpus -1 --repos 'https://mran.revolutionanalytics.com/snapshot/2020-09-28' \ - assertr \ - here \ - ggforce \ - janitor \ - jpndistrict \ - lwgeom \ - parzer \ - pkgload \ - rnaturalearth \ - roxygen2 \ - roxygen2md \ - usethis && \ - installGithub.r \ - ropenscilabs/rnaturalearthhires && \ - rm -rf /tmp/downloaded_packages/ /tmp/*.rds diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 91cf0ea..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3.8" -services: - rstudio: - build: - context: "." - args: - - GITHUB_PAT=${GITHUB_PAT} - ports: - - "8787:8787" - volumes: - - ".:/home/rstudio/jmastats" - environment: - PASSWORD: ${PASSWORD} From ffcd469e6e24d40744a5065f0dca90f0ddea76ef Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Tue, 5 Sep 2023 22:54:50 +0900 Subject: [PATCH 03/17] Update --- DESCRIPTION | 2 +- LICENSE | 2 +- LICENSE.md | 2 +- README.Rmd | 9 +++++++++ README.md | 8 ++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d7e5cdd..6d10e03 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: jmastats -Version: 0.1.0.9000 +Version: 0.2.0 Title: Download Weather Data from Japan Meteorological Agency Website Description: This package provides features that allow users to download weather data published by the Japan Meteorological Agency website diff --git a/LICENSE b/LICENSE index 17787e1..6535dd8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2022 +YEAR: 2022-2023 COPYRIGHT HOLDER: jmastats authors diff --git a/LICENSE.md b/LICENSE.md index e3ff66f..85840c8 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # MIT License -Copyright (c) 2022 Shinya Uryu +Copyright (c) 2022-2023 Shinya Uryu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.Rmd b/README.Rmd index c8a8f7a..88fc481 100644 --- a/README.Rmd +++ b/README.Rmd @@ -121,6 +121,15 @@ data("stations", package = "jmastats") | 雨 | 有線ロボット気象計 | 降水量 | | 雪 | 有線ロボット積雪計 | 積雪量 | +## 引用 + +このパッケージを利用した学術論文の出版、学会発表等を行う際は次のように引用を行ってください。 + +> Uryu S (2023). _jmastats: Download Weather Data from Japan + Meteorological Agency Website_. R package version 0.2.0, + . + + ## 関連するパッケージ - [worldmet](https://cran.r-project.org/package=worldmet) diff --git a/README.md b/README.md index 4c46ff0..99a3441 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,14 @@ data("stations", package = "jmastats") | 雨 | 有線ロボット気象計 | 降水量 | | 雪 | 有線ロボット積雪計 | 積雪量 | +## 引用 + +このパッケージを利用した学術論文の出版、学会発表等を行う際は次のように引用を行ってください。 + +> Uryu S (2023). *jmastats: Download Weather Data from Japan +> Meteorological Agency Website*. R package version 0.2.0, +> . + ## 関連するパッケージ - [worldmet](https://cran.r-project.org/package=worldmet) From cceac56b6a08e6015150cc4a79a1c2ac11ed8095 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Wed, 6 Sep 2023 08:29:57 +0900 Subject: [PATCH 04/17] =?UTF-8?q?[modify]CRAN=E3=81=8B=E3=82=89=E3=81=AE?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.Rmd | 12 +++++++++--- README.md | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.Rmd b/README.Rmd index 88fc481..e978f9b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,16 +20,22 @@ knitr::opts_chunk$set( -jmastats は[気象庁](https://www.jma.go.jp/jma/index.html)のウェブサイトで公開される気象、海洋等の各種データをR上で扱えるようにするパッケージです。 +jmastats は[気象庁](https://www.jma.go.jp/jma/index.html)のウェブサイトで公開される気象、地震、海洋等の各種データをR上で扱うためのパッケージです。 ## インストール -パッケージはCRANに登録されていません。次のコマンドを実行することでインストールが行われます。 +CRANからインストールが可能です。 + +``` r +install.packages("jmastats") +``` + +開発版を利用したい場合は次のコマンドを実行することでインストールが行われます。 ``` r install.packages( "jmastats", - repos = c(mm = "https://uribo.r-universe.dev", getOption("repos"))) + repos = c(uribo = "https://uribo.r-universe.dev", getOption("repos"))) ``` ## 特徴 diff --git a/README.md b/README.md index 99a3441..5a13f47 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,22 @@ jmastats -は[気象庁](https://www.jma.go.jp/jma/index.html)のウェブサイトで公開される気象、海洋等の各種データをR上で扱えるようにするパッケージです。 +は[気象庁](https://www.jma.go.jp/jma/index.html)のウェブサイトで公開される気象、地震、海洋等の各種データをR上で扱うためのパッケージです。 ## インストール -パッケージはCRANに登録されていません。次のコマンドを実行することでインストールが行われます。 +CRANからインストールが可能です。 + +``` r +install.packages("jmastats") +``` + +開発版を利用したい場合は次のコマンドを実行することでインストールが行われます。 ``` r install.packages( "jmastats", - repos = c(mm = "https://uribo.r-universe.dev", getOption("repos"))) + repos = c(uribo = "https://uribo.r-universe.dev", getOption("repos"))) ``` ## 特徴 From d920b9e0126609d5fd4cfd62f47fb5c876cb6360 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Wed, 6 Sep 2023 16:08:48 +0900 Subject: [PATCH 05/17] Update --- DESCRIPTION | 6 +++--- README.Rmd | 21 ++++++++++++++++++++- README.md | 21 ++++++++++++++++++++- cran-comments.md | 1 + 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6d10e03..2026bd0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: jmastats Version: 0.2.0 Title: Download Weather Data from Japan Meteorological Agency Website -Description: This package provides features that allow users to download - weather data published by the Japan Meteorological Agency website +Description: Provides features that allow users to download + weather data published by the Japan Meteorological Agency (JMA) website (). The data includes information dating back to 1976 and aligns with the categories available on the website. Additionally, users can process the best track data of typhoons and easily @@ -10,7 +10,7 @@ Description: This package provides features that allow users to download Authors@R: c(person(given = "Shinya", family = "Uryu", email = "suika1127@gmail.com", - role = c("aut", "cre"), + role = c("aut", "cph", "cre"), comment = c(ORCID = "0000-0002-0493-6186"))) Depends: R (>= 4.1) diff --git a/README.Rmd b/README.Rmd index e978f9b..02a8ef2 100644 --- a/README.Rmd +++ b/README.Rmd @@ -58,15 +58,26 @@ library(jmastats) 取得したい対象データを`item`引数に指定、観測所の位置する `block_no` と対象の年 `year` 月 `month` 日 `day`を必要に応じて与えて実行します。 ```{r} +# データの種類: hourly (1時間ごとの値) +# ブロック番号: 47646 (「つくば」) +# 対象年月日: 2022年1月1日 jma_collect(item = "hourly", block_no = 47646, year = 2022, month = 1, day = 1) ``` -`block_no` が不明の時は 対象地点の緯度経度を元に`nearest_station()`で検索できます。 +`block_no` が不明の時は 対象地点の緯度経度を元に`nearest_station()`関数や後述の気象観測地点データから検索できます。 ```{r} +# 任意の緯度経度座標から最寄りの観測所と座標との距離を出力 nearest_station(longitude = 140.112, latitude = 36.083) ``` +ユーザーが任意の地点、項目、期間等の組みあわせで出力可能な、`過去の気象データ`のcsvファイルを読み込む関数として`read_jma_weather()`関数が利用できます。 + +```{r} +# ダウンロードしたcsvファイルのパスを与えて実行します +read_jma_weather(system.file("dummy/dl_data.csv", package = "jmastats")) +``` + ### 台風資料 気象庁のウェブサイト、[RMCS Tokyo](https://www.jma.go.jp/jma/jma-eng/jma-center/rsmc-hp-pub-eg/trackarchives.html)が提供する台風のベストトラックデータを読み込むための関数があります。 @@ -92,6 +103,14 @@ read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) | track_combine(group_vars = "storm_name") ``` +### 気象庁防災情報XMLフォーマット + +```{r} +read_kishou_feed("high", type = "regular") + +read_kishou_feed("low", "other") +``` + ### 潮汐観測資料 ```{r} diff --git a/README.md b/README.md index 5a13f47..85787eb 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,27 @@ library(jmastats) と対象の年 `year` 月 `month` 日 `day`を必要に応じて与えて実行します。 ``` r +# データの種類: hourly (1時間ごとの値) +# ブロック番号: 47646 (「つくば」) +# 対象年月日: 2022年1月1日 jma_collect(item = "hourly", block_no = 47646, year = 2022, month = 1, day = 1) ``` `block_no` が不明の時は -対象地点の緯度経度を元に`nearest_station()`で検索できます。 +対象地点の緯度経度を元に`nearest_station()`関数や後述の気象観測地点データから検索できます。 ``` r +# 任意の緯度経度座標から最寄りの観測所と座標との距離を出力 nearest_station(longitude = 140.112, latitude = 36.083) ``` +ユーザーが任意の地点、項目、期間等の組みあわせで出力可能な、`過去の気象データ`のcsvファイルを読み込む関数として`read_jma_weather()`関数が利用できます。 + +``` r +# ダウンロードしたcsvファイルのパスを与えて実行します +read_jma_weather(system.file("dummy/dl_data.csv", package = "jmastats")) +``` + ### 台風資料 気象庁のウェブサイト、[RMCS @@ -103,6 +114,14 @@ read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) | track_combine(group_vars = "storm_name") ``` +### 気象庁防災情報XMLフォーマット + +``` r +read_kishou_feed("high", type = "regular") + +read_kishou_feed("low", "other") +``` + ### 潮汐観測資料 ``` r diff --git a/cran-comments.md b/cran-comments.md index 858617d..cb49223 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -3,3 +3,4 @@ 0 errors | 0 warnings | 1 note * This is a new release. +* `JMA` is not misspell in DESCRIPTION From 0d36c57854c82f46ba3c9e93e275df765abb9a2a Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Wed, 6 Sep 2023 16:09:44 +0900 Subject: [PATCH 06/17] =?UTF-8?q?[modify]return=E3=81=A8examples=E9=A0=85?= =?UTF-8?q?=E7=9B=AE=E3=81=AE=E8=A6=8B=E7=9B=B4=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NAMESPACE | 1 + R/appdir.R | 8 +++++++- R/ggplot2_scales.R | 9 ++++----- R/jma_collect.R | 14 ++++++-------- R/kishou_feed.R | 6 +++--- R/nearest_station.R | 2 -- R/parse_unit.R | 4 ++++ R/pivot_tide_level.R | 4 ++-- R/read_eqdb.R | 3 ++- R/read_jma_weather.R | 7 +++++-- R/read_tide_level.R | 7 ++++--- R/track.R | 6 +++++- R/utils.R | 2 +- inst/dummy/dl_data.csv | 6 ++++++ man/ggplot2-scales.Rd | 10 +++++----- man/jma_collect.Rd | 5 ++++- man/nearest_station.Rd | 2 -- man/parse_unit.Rd | 7 +++++++ man/pivot_tide_level.Rd | 4 ++-- man/read_eqdb_csv.Rd | 3 +++ man/read_jma_weather.Rd | 6 ++++++ man/read_kishou_feed.Rd | 6 +++--- man/read_tide_level.Rd | 5 ++++- man/reset_cache.Rd | 9 ++++++++- man/track.Rd | 11 +++++++++-- 25 files changed, 101 insertions(+), 46 deletions(-) create mode 100644 inst/dummy/dl_data.csv diff --git a/NAMESPACE b/NAMESPACE index db768ef..2a9548e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -70,6 +70,7 @@ importFrom(tidyselect,all_of) importFrom(tidyselect,where) importFrom(units,as_units) importFrom(units,set_units) +importFrom(utils,askYesNo) importFrom(utils,read.table) importFrom(xml2,read_html) importFrom(xml2,url_parse) diff --git a/R/appdir.R b/R/appdir.R index babf862..9e9a346 100644 --- a/R/appdir.R +++ b/R/appdir.R @@ -1,9 +1,15 @@ -#' Remove cache files +#' Remove all cache files #' #' @description Remove all package cache files. +#' @importFrom utils askYesNo +#' @examples +#' if (interactive()) +#' reset_cache() #' @rdname reset_cache #' @export +#' @return None reset_cache <- function() { +if (utils::askYesNo("Delete all cache files. Is it OK?")) unlink(rappdirs::user_cache_dir("jmastats"), recursive = TRUE) } diff --git a/R/ggplot2_scales.R b/R/ggplot2_scales.R index 358c98e..90cc845 100644 --- a/R/ggplot2_scales.R +++ b/R/ggplot2_scales.R @@ -7,7 +7,6 @@ #' @name ggplot2-scales #' @rdname ggplot2-scales #' @examples -#' \dontrun{ #' library(dplyr) #' d <- #' jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> @@ -16,14 +15,14 @@ #' #' library(ggplot2) #' library(units) -#' ggplot(d, aes(date, precipitation_sum_mm, -#' color = units::drop_units(precipitation_sum_mm), -#' fill = units::drop_units(precipitation_sum_mm))) + +#' ggplot(d, aes(date, precipitation_sum, +#' color = drop_units(precipitation_sum), +#' fill = drop_units(precipitation_sum))) + #' geom_bar(stat = "identity") + #' scale_color_jma_absolute(type = "precipitation") + #' scale_fill_jma_absolute(type = "precipitation") -#' } #' @export +#' @return gg scale object scale_color_jma_absolute <- function(type = "precipitation", ...) { pal <- diff --git a/R/jma_collect.R b/R/jma_collect.R index 3052040..854dbe5 100644 --- a/R/jma_collect.R +++ b/R/jma_collect.R @@ -36,7 +36,7 @@ #' - rank: Values of the largest in the history of observations #' for each location. #' @examples -#' \dontrun{ +#' \donttest{ #' jma_collect(item = "annually", "1284", year = 2017, month = 11) #' # daily #' jma_collect(item = "daily", block_no = "0010", year = 2017, month = 11) @@ -47,6 +47,7 @@ #' jma_collect("rank", block_no = "47646", year = 2020) #' } #' @export +#' @return a `tbl` object jma_collect <- function(item = NULL, block_no, year, month, day, cache = TRUE, pack = TRUE, quiet = FALSE) { @@ -107,8 +108,7 @@ pack_df <- function(df, unpack = FALSE) { } } -jma_collect_raw <- function(item = NULL, - block_no, year, month, day, quiet) { +jma_collect_raw <- function(item = NULL, block_no, year, month, day, quiet) { target <- detect_target(item, block_no, year, month, day) @@ -360,8 +360,7 @@ detect_station_info <- function(.blockid) { intToUtf8(c(32701, 30000)), intToUtf8(c(38745, 23713, 31354, 28207)), intToUtf8(c(26494, 23665, 21335, 21513, 30000)), - intToUtf8(c(36196, 27743)) - ), + intToUtf8(c(36196, 27743))), # Special pattern "a", station_type) @@ -419,9 +418,8 @@ note_vars <- function(var) { } note_message <- function(var) { - res <- - note_vars(var) |> - purrr::keep(~ length(.x) > 0) + note_vars(var) |> + purrr::keep(\(x) length(x) > 0) } jma_vars <- list(atmosphere = paste0("atmosphere_", diff --git a/R/kishou_feed.R b/R/kishou_feed.R index 0100bd2..0071f22 100644 --- a/R/kishou_feed.R +++ b/R/kishou_feed.R @@ -8,13 +8,13 @@ #' - extra: It will be announced at any time. #' - eqvol: Earthquakes and Volcanoes. #' - other: Other informations. -#' @seealso [https://xml.kishou.go.jp/index.html](https://xml.kishou.go.jp/index.html) +#' @seealso #' @examples -#' \dontrun{ +#' \donttest{ #' read_kishou_feed("high", type = "regular") #' read_kishou_feed("low", "other") #' } -#' @return data.frame +#' @return a `tbl` object #' @export read_kishou_feed <- function(frequency, type) { x <- diff --git a/R/nearest_station.R b/R/nearest_station.R index 0f4e1b6..17f6708 100644 --- a/R/nearest_station.R +++ b/R/nearest_station.R @@ -22,7 +22,6 @@ #' @importFrom sf st_distance st_point st_set_geometry st_sfc #' @importFrom units as_units set_units #' @examples -#' \dontrun{ #' nearest_station(142.9313, 43.70417) #' #' pick_neighbor_stations(140.10, 36.08, 300000) @@ -35,7 +34,6 @@ #' pick_neighbor_tide_stations(longitude = 133.4375, latitude = 34.45833, #' year = 2020, #' distance = 100, .unit = "km") -#' } #' @name nearest_station NULL diff --git a/R/parse_unit.R b/R/parse_unit.R index 88978af..1644e36 100644 --- a/R/parse_unit.R +++ b/R/parse_unit.R @@ -7,7 +7,11 @@ #' @importFrom stringr str_subset #' @importFrom tidyselect all_of where #' @importFrom units as_units +#' @examples +#' jma_collect("hourly", "0010", 2018, 7, 30) |> +#' parse_unit(rename = TRUE) #' @export +#' @return a `tbl` object parse_unit <- function(data, rename = TRUE) { original_vars <- diff --git a/R/pivot_tide_level.R b/R/pivot_tide_level.R index 999dd4e..359c101 100644 --- a/R/pivot_tide_level.R +++ b/R/pivot_tide_level.R @@ -2,12 +2,12 @@ #' #' @param data tidal level data #' @examples -#' \dontrun{ +#' \donttest{ #' read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") |> #' pivot_tide_level() #' } #' @seealso [read_tide_level()] -#' @return List to store two datasets. hourly observation data and tide. +#' @return List to store two datasets containing hourly and tide level data. #' @export pivot_tide_level <- function(data) { list( diff --git a/R/read_eqdb.R b/R/read_eqdb.R index 7ba8f75..471a60c 100644 --- a/R/read_eqdb.R +++ b/R/read_eqdb.R @@ -5,8 +5,9 @@ #' @examples #' read_eqdb_csv(system.file("dummy/eqdb.csv", package = "jmastats")) #' @rdname read_eqdb_csv -#' @seealso [https://www.data.jma.go.jp/svd/eqdb/data/shindo/index.html](https://www.data.jma.go.jp/svd/eqdb/data/shindo/index.html) +#' @seealso #' @export +#' @return a `tbl` object read_eqdb_csv <- function(path, show_metadata = TRUE) { if (show_metadata == TRUE) { meta <- diff --git a/R/read_jma_weather.R b/R/read_jma_weather.R index d3ce13c..559fdcf 100644 --- a/R/read_jma_weather.R +++ b/R/read_jma_weather.R @@ -1,9 +1,12 @@ #' Read the past weather #' @description Read the past weather data files downloaded from JMA. #' @param path The path to the downloaded file. -#' @seealso [https://www.data.jma.go.jp/gmd/risk/obsdl/index.php](https://www.data.jma.go.jp/gmd/risk/obsdl/index.php), -#' [https://www.data.jma.go.jp/gmd/risk/obsdl/top/help3.html](https://www.data.jma.go.jp/gmd/risk/obsdl/top/help3.html) +#' @seealso , +#' +#' @examples +#' read_jma_weather(system.file("dummy/dl_data.csv", package = "jmastats")) #' @export +#' @return a `tbl` object read_jma_weather <- function(path) { var_st_names <- station_head_info(path) diff --git a/R/read_tide_level.R b/R/read_tide_level.R index b90fa94..f596d47 100644 --- a/R/read_tide_level.R +++ b/R/read_tide_level.R @@ -5,14 +5,15 @@ #' @param .month Month number. 1997 only, valid after March. #' @param .stn Station identification name in uppercase two-digit letters. #' @param raw If *TRUE*, return raw format data -#' @seealso [https://www.data.jma.go.jp/gmd/kaiyou/db/tide/suisan/readme.html](https://www.data.jma.go.jp/gmd/kaiyou/db/tide/suisan/readme.html) +#' @seealso #' @examples -#' \dontrun{ +#' \donttest{ #' read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") #' #' read_tide_level(.year = 2020, .month = 2, .stn = "TK") #' } #' @export +#' @return a `tbl` object read_tide_level <- function(path = NULL, .year, .month, .stn, raw = FALSE) { if (is.null(path)) { path <- @@ -43,7 +44,7 @@ read_tide_level <- function(path = NULL, .year, .month, .stn, raw = FALSE) { } request_tide_level_url <- function(.year, .month, .stn) { - jma_site <- + jma_site <- # nolint "https://www.data.jma.go.jp" year <- check_input_tidal_year(.year) diff --git a/R/track.R b/R/track.R index a3315cc..579be0e 100644 --- a/R/track.R +++ b/R/track.R @@ -20,11 +20,15 @@ #' @importFrom tibble as_tibble #' @importFrom tidyr extract #' @importFrom utils read.table -#' @details See for more details. +#' @seealso #' @rdname track #' @examples #' read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) +#' +#' read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) |> +#' track_combine() #' @export +#' @return a `tbl` object read_rsmc_besttrack <- function(path) { last_update <- international_number <- storm_name <- diff --git a/R/utils.R b/R/utils.R index e722a57..0eede3c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -35,7 +35,7 @@ validate_date <- function(year, month, day) { check_input_coords <- function(longitude, latitude, geometry = NULL) { if (!is.null(geometry)) { - if (!rlang::is_missing(longitude) | !rlang::is_missing(latitude)) { + if (!rlang::is_missing(longitude) || !rlang::is_missing(latitude)) { rlang::inform("the condition assigned coord and geometry, only the geometry will be used") # nolint } if (sf::st_is(geometry, "POINT")) { diff --git a/inst/dummy/dl_data.csv b/inst/dummy/dl_data.csv new file mode 100644 index 0000000..f1e1f39 --- /dev/null +++ b/inst/dummy/dl_data.csv @@ -0,0 +1,6 @@ +_E[hF2023/09/06 13:25:25 + +,,,,,,, +N,ϋC(),ϋC(),ϋC(),~ʂ̍v(mm),~ʂ̍v(mm),~ʂ̍v(mm),~ʂ̍v(mm) +,,i,ώԍ,,ۂȂ,i,ώԍ +2023/8/5,29.1,8,1,4.5,0,8,1 diff --git a/man/ggplot2-scales.Rd b/man/ggplot2-scales.Rd index 2d4dbf2..5beda4f 100644 --- a/man/ggplot2-scales.Rd +++ b/man/ggplot2-scales.Rd @@ -24,12 +24,13 @@ scale_fill_jma_relative(type = "amedas", ...) } \value{ A \code{ScaleContinuous} object that can be added to a \code{ggplot} object + +gg scale object } \description{ Scales to use for ggplot2 } \examples{ -\dontrun{ library(dplyr) d <- jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> @@ -38,11 +39,10 @@ parse_unit() library(ggplot2) library(units) -ggplot(d, aes(date, precipitation_sum_mm, - color = units::drop_units(precipitation_sum_mm), - fill = units::drop_units(precipitation_sum_mm))) + +ggplot(d, aes(date, precipitation_sum, + color = drop_units(precipitation_sum), + fill = drop_units(precipitation_sum))) + geom_bar(stat = "identity") + scale_color_jma_absolute(type = "precipitation") + scale_fill_jma_absolute(type = "precipitation") } -} diff --git a/man/jma_collect.Rd b/man/jma_collect.Rd index e596e17..8469576 100644 --- a/man/jma_collect.Rd +++ b/man/jma_collect.Rd @@ -38,6 +38,9 @@ numeric value is specified, it is processed as a string.} row combinations that were treated as missing values for some reason. (\code{TRUE}, the default)} } +\value{ +a \code{tbl} object +} \description{ Refer to the data available in the JMA Historical Weather Data Search. Executed by specifying the target location and date. @@ -58,7 +61,7 @@ for each location. } } \examples{ -\dontrun{ +\donttest{ jma_collect(item = "annually", "1284", year = 2017, month = 11) # daily jma_collect(item = "daily", block_no = "0010", year = 2017, month = 11) diff --git a/man/nearest_station.Rd b/man/nearest_station.Rd index afae9ac..a3baa0c 100644 --- a/man/nearest_station.Rd +++ b/man/nearest_station.Rd @@ -55,7 +55,6 @@ Filter by distance from target point. } } \examples{ -\dontrun{ nearest_station(142.9313, 43.70417) pick_neighbor_stations(140.10, 36.08, 300000) @@ -69,4 +68,3 @@ pick_neighbor_tide_stations(longitude = 133.4375, latitude = 34.45833, year = 2020, distance = 100, .unit = "km") } -} diff --git a/man/parse_unit.Rd b/man/parse_unit.Rd index 5ff6cba..f93533b 100644 --- a/man/parse_unit.Rd +++ b/man/parse_unit.Rd @@ -11,6 +11,13 @@ parse_unit(data, rename = TRUE) \item{rename}{\emph{logical}} } +\value{ +a \code{tbl} object +} \description{ Parse data variable units } +\examples{ +jma_collect("hourly", "0010", 2018, 7, 30) |> + parse_unit(rename = TRUE) +} diff --git a/man/pivot_tide_level.Rd b/man/pivot_tide_level.Rd index fabc837..a5ed04f 100644 --- a/man/pivot_tide_level.Rd +++ b/man/pivot_tide_level.Rd @@ -10,13 +10,13 @@ pivot_tide_level(data) \item{data}{tidal level data} } \value{ -List to store two datasets. hourly observation data and tide. +List to store two datasets containing hourly and tide level data. } \description{ Convert and split tidal level data } \examples{ -\dontrun{ +\donttest{ read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") |> pivot_tide_level() } diff --git a/man/read_eqdb_csv.Rd b/man/read_eqdb_csv.Rd index 019eea4..369987f 100644 --- a/man/read_eqdb_csv.Rd +++ b/man/read_eqdb_csv.Rd @@ -12,6 +12,9 @@ read_eqdb_csv(path, show_metadata = TRUE) \item{show_metadata}{logical. If \emph{FALSE}, returns only the values observed at each location.} } +\value{ +a \code{tbl} object +} \description{ Read the csv of the earthquake database } diff --git a/man/read_jma_weather.Rd b/man/read_jma_weather.Rd index c7147ec..e116086 100644 --- a/man/read_jma_weather.Rd +++ b/man/read_jma_weather.Rd @@ -9,9 +9,15 @@ read_jma_weather(path) \arguments{ \item{path}{The path to the downloaded file.} } +\value{ +a \code{tbl} object +} \description{ Read the past weather data files downloaded from JMA. } +\examples{ +read_jma_weather(system.file("dummy/dl_data.csv", package = "jmastats")) +} \seealso{ \url{https://www.data.jma.go.jp/gmd/risk/obsdl/index.php}, \url{https://www.data.jma.go.jp/gmd/risk/obsdl/top/help3.html} diff --git a/man/read_kishou_feed.Rd b/man/read_kishou_feed.Rd index c24e778..3391a01 100644 --- a/man/read_kishou_feed.Rd +++ b/man/read_kishou_feed.Rd @@ -14,7 +14,7 @@ long term ("low")} See details for the items.} } \value{ -data.frame +a \code{tbl} object } \description{ Read Kishou Disaster Prevention Information Feed @@ -29,11 +29,11 @@ The following items can be specified in the type argument. } } \examples{ -\dontrun{ +\donttest{ read_kishou_feed("high", type = "regular") read_kishou_feed("low", "other") } } \seealso{ -\url{https://xml.kishou.go.jp/index.html} +\url{https://xml.kishou.go.jp} } diff --git a/man/read_tide_level.Rd b/man/read_tide_level.Rd index 945b79c..1837d94 100644 --- a/man/read_tide_level.Rd +++ b/man/read_tide_level.Rd @@ -17,11 +17,14 @@ read_tide_level(path = NULL, .year, .month, .stn, raw = FALSE) \item{raw}{If \emph{TRUE}, return raw format data} } +\value{ +a \code{tbl} object +} \description{ Read and parse tide level text data } \examples{ -\dontrun{ +\donttest{ read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") read_tide_level(.year = 2020, .month = 2, .stn = "TK") diff --git a/man/reset_cache.Rd b/man/reset_cache.Rd index 7f39f0e..59e7b2f 100644 --- a/man/reset_cache.Rd +++ b/man/reset_cache.Rd @@ -2,10 +2,17 @@ % Please edit documentation in R/appdir.R \name{reset_cache} \alias{reset_cache} -\title{Remove cache files} +\title{Remove all cache files} \usage{ reset_cache() } +\value{ +None +} \description{ Remove all package cache files. } +\examples{ +if (interactive()) + reset_cache() +} diff --git a/man/track.Rd b/man/track.Rd index 9aea362..73dab2e 100644 --- a/man/track.Rd +++ b/man/track.Rd @@ -26,6 +26,9 @@ in the user's computer or the URL.} \item{geometry}{geometry column name (default \code{geometry}).} } +\value{ +a \code{tbl} object +} \description{ Tidy formatting best track data and combine each point to line. } @@ -36,9 +39,13 @@ contains observation record as point. \item \code{track_combine()}: Combine track data to line by id (such as international_number and storm_name). } - -See \url{https://www.jma.go.jp/jma/jma-eng/jma-center/rsmc-hp-pub-eg/RSMC_HP.htm} for more details. } \examples{ read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) + +read_rsmc_besttrack(path = system.file("dummy/bst.txt", package = "jmastats")) |> + track_combine() +} +\seealso{ +\url{https://www.jma.go.jp/jma/jma-eng/jma-center/rsmc-hp-pub-eg/RSMC_HP.htm} } From 846754bdea32321b3c61abf22dce6baa0541cc8d Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Wed, 6 Sep 2023 17:34:17 +0900 Subject: [PATCH 07/17] [modify]don't test --- R/ggplot2_scales.R | 4 ++-- man/ggplot2-scales.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/ggplot2_scales.R b/R/ggplot2_scales.R index 90cc845..f6293d8 100644 --- a/R/ggplot2_scales.R +++ b/R/ggplot2_scales.R @@ -7,10 +7,9 @@ #' @name ggplot2-scales #' @rdname ggplot2-scales #' @examples -#' library(dplyr) +#' \donttest{ #' d <- #' jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> -#' select(date, `precipitation_sum(mm)`, starts_with("temperature"), starts_with("sunshine")) |> #' parse_unit() #' #' library(ggplot2) @@ -21,6 +20,7 @@ #' geom_bar(stat = "identity") + #' scale_color_jma_absolute(type = "precipitation") + #' scale_fill_jma_absolute(type = "precipitation") +#' } #' @export #' @return gg scale object scale_color_jma_absolute <- function(type = "precipitation", ...) { diff --git a/man/ggplot2-scales.Rd b/man/ggplot2-scales.Rd index 5beda4f..4fe74ac 100644 --- a/man/ggplot2-scales.Rd +++ b/man/ggplot2-scales.Rd @@ -31,10 +31,9 @@ gg scale object Scales to use for ggplot2 } \examples{ -library(dplyr) +\donttest{ d <- jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> -select(date, `precipitation_sum(mm)`, starts_with("temperature"), starts_with("sunshine")) |> parse_unit() library(ggplot2) @@ -46,3 +45,4 @@ ggplot(d, aes(date, precipitation_sum, scale_color_jma_absolute(type = "precipitation") + scale_fill_jma_absolute(type = "precipitation") } +} From b9565a59e35575e7265483904098072895bbdc8c Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Thu, 7 Sep 2023 09:16:26 +0900 Subject: [PATCH 08/17] [fix]set crs --- R/nearest_station.R | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/R/nearest_station.R b/R/nearest_station.R index 17f6708..c132af7 100644 --- a/R/nearest_station.R +++ b/R/nearest_station.R @@ -97,16 +97,18 @@ pick_neighbor_stations <- function(longitude, latitude, distance = 1, .unit = "m sf::st_point(c(coords$longitude, coords$latitude)), crs = 4326) - stations[which(sf::st_is_within_distance( - coords, - stations, - dist = units::as_units(distance, value = unit), - sparse = FALSE)[1, ]), ] |> - dplyr::mutate( - distance = sf::st_distance( - geometry, - coords)[, 1] - ) |> + tgt_st <- + stations[which(sf::st_is_within_distance( + coords, + stations, + dist = units::as_units(distance, value = unit), + sparse = FALSE)[1, ]), ] + tgt_st$distance <- + sf::st_distance( + coords, + sf::st_transform(tgt_st$geometry, 4326), + by_element = FALSE)[1, ] + tgt_st |> dplyr::select( area, station_no, @@ -139,6 +141,7 @@ pick_neighbor_tide_stations <- function(year, longitude, latitude, stations, dist = units::as_units(distance, value = unit), sparse = FALSE)[1, ]), ] |> + sf::st_transform(crs = 4326) |> dplyr::mutate(distance = sf::st_distance( geometry, coords)[, 1]) |> From 881387ff3d7888a54b6769b8112188450fe4eb07 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Thu, 7 Sep 2023 09:21:40 +0900 Subject: [PATCH 09/17] update --- cran-comments.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index cb49223..896ce0a 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,36 @@ +## Test environments + +* macOS Ventura (13.4) install, R 4.3.1 (local) +* win-builder (devel and release) +* Rhub: Ubuntu Linux 20.04.1 LTS, R-release, GCC +* Rhub: Debian Linux, R-release, GCC + ## R CMD check results -0 errors | 0 warnings | 1 note +0 errors | 0 warnings | 3 note * This is a new release. -* `JMA` is not misspell in DESCRIPTION +* checking data for non-ASCII characters ... NOTE + Note: found 16726 marked UTF-8 strings +* checking CRAN incoming feasibility ... [18s] NOTE + +``` +Maintainer: 'Shinya Uryu ' + + New submission + + Possibly misspelled words in DESCRIPTION: + JMA (5:62) + + Package has a VignetteBuilder field but no prebuilt vignette index. + +Found the following (possibly) invalid URLs: + URL: https://xml.kishou.go.jp + From: man/read_kishou_feed.Rd + Status: Error + Message: libcurl error code 35: + schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log. +``` + +* The possible misspellings are in fact all correct. Indicates the abbreviation of the organization's name. +* I have checked the URL is correct. From b2ef5006429a1331fbccb87ad59656e0451bb707 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Thu, 7 Sep 2023 09:39:09 +0900 Subject: [PATCH 10/17] Update --- NEWS.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5468858..549e74d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,19 @@ -# jmastats (development version) +# jmastats 0.2.0 + +* Initial release for CRAN. + +## Features + +* Added an interval when executing `jma_collect()` for reducing the load on the server. +* A message is displayed when the data obtained by `jma_collect()` contains values such as missing values. + +## Fixes + +* Fixed an issue with parameters when acquiring data with `jma_collect()`. + +## Datasets + +* Various datasets handled by the package have been updated to the latest version in March 2023. # jmastats 0.1.0 From 3fcf9661a83d138ec63037dbabe6e8aca73fe771 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Thu, 7 Sep 2023 17:16:06 +0900 Subject: [PATCH 11/17] [fix]cran notes --- .Rbuildignore | 1 + DESCRIPTION | 1 - cran-comments.md | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index c1ab434..053b1e1 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,4 @@ ^inst/\.gitignore$ ^inst/real$ ^cran-comments\.md$ +^CRAN-SUBMISSION$ diff --git a/DESCRIPTION b/DESCRIPTION index 2026bd0..671f134 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,6 +44,5 @@ Suggests: Encoding: UTF-8 LazyData: true ByteCompile: true -VignetteBuilder: knitr RoxygenNote: 7.2.3 Roxygen: list(markdown = TRUE) diff --git a/cran-comments.md b/cran-comments.md index 896ce0a..9255ba1 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -10,6 +10,7 @@ 0 errors | 0 warnings | 3 note * This is a new release. +* Remove `VignetteBuilder` filed in DESCRIPTION. * checking data for non-ASCII characters ... NOTE Note: found 16726 marked UTF-8 strings * checking CRAN incoming feasibility ... [18s] NOTE @@ -21,8 +22,6 @@ Maintainer: 'Shinya Uryu ' Possibly misspelled words in DESCRIPTION: JMA (5:62) - - Package has a VignetteBuilder field but no prebuilt vignette index. Found the following (possibly) invalid URLs: URL: https://xml.kishou.go.jp From d5dcb7cf06d917a66a0018251baa5258ae6845ab Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Fri, 8 Sep 2023 11:08:13 +0900 Subject: [PATCH 12/17] [add]life-cycle badge --- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/appdir.R | 5 +++- R/ggplot2_scales.R | 4 ++++ R/jma_collect.R | 2 ++ R/jmastats-package.R | 7 ++++++ R/jmastats.R | 7 ------ R/kishou_feed.R | 3 +++ R/nearest_station.R | 7 +++--- R/parse_unit.R | 3 +++ R/pivot_tide_level.R | 3 +++ R/read_eqdb.R | 3 +++ R/read_jma_weather.R | 5 +++- R/read_tide_level.R | 3 +++ R/track.R | 5 +++- man/figures/lifecycle-archived.svg | 21 ++++++++++++++++ man/figures/lifecycle-defunct.svg | 21 ++++++++++++++++ man/figures/lifecycle-deprecated.svg | 21 ++++++++++++++++ man/figures/lifecycle-experimental.svg | 21 ++++++++++++++++ man/figures/lifecycle-maturing.svg | 21 ++++++++++++++++ man/figures/lifecycle-questioning.svg | 21 ++++++++++++++++ man/figures/lifecycle-soft-deprecated.svg | 21 ++++++++++++++++ man/figures/lifecycle-stable.svg | 29 +++++++++++++++++++++++ man/figures/lifecycle-superseded.svg | 21 ++++++++++++++++ man/ggplot2-scales.Rd | 4 +--- man/jma_collect.Rd | 2 ++ man/jmastats-package.Rd | 25 +++++++++++++++++++ man/jmastats.Rd | 10 -------- man/nearest_station.Rd | 7 +++--- man/parse_unit.Rd | 2 +- man/pivot_tide_level.Rd | 2 +- man/read_eqdb_csv.Rd | 2 +- man/read_jma_weather.Rd | 2 ++ man/read_kishou_feed.Rd | 2 +- man/read_tide_level.Rd | 2 +- man/reset_cache.Rd | 2 ++ man/track.Rd | 2 ++ 37 files changed, 287 insertions(+), 35 deletions(-) create mode 100644 R/jmastats-package.R delete mode 100644 R/jmastats.R create mode 100644 man/figures/lifecycle-archived.svg create mode 100644 man/figures/lifecycle-defunct.svg create mode 100644 man/figures/lifecycle-deprecated.svg create mode 100644 man/figures/lifecycle-experimental.svg create mode 100644 man/figures/lifecycle-maturing.svg create mode 100644 man/figures/lifecycle-questioning.svg create mode 100644 man/figures/lifecycle-soft-deprecated.svg create mode 100644 man/figures/lifecycle-stable.svg create mode 100644 man/figures/lifecycle-superseded.svg create mode 100644 man/jmastats-package.Rd delete mode 100644 man/jmastats.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 671f134..47bdafc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,10 +19,11 @@ BugReports: https://github.com/uribo/jmastats/issues URL: https://github.com/uribo/jmastats Imports: cli (>= 3.4.0), - crayon (>= 1.3.4), + crayon (>= 1.3.4), dplyr (>= 1.1.0), forcats (>= 0.4.0), ggplot2 (>= 2.2.1), + lifecycle (>= 1.0.3), lubridate (>= 1.7.4), purrr (>= 1.0.2), rappdirs (>= 0.3.3), diff --git a/NAMESPACE b/NAMESPACE index 2a9548e..0ff5852 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -35,6 +35,7 @@ importFrom(dplyr,ungroup) importFrom(forcats,fct_inorder) importFrom(ggplot2,scale_color_gradientn) importFrom(ggplot2,scale_fill_gradientn) +importFrom(lifecycle,deprecated) importFrom(lubridate,ymd_h) importFrom(purrr,keep) importFrom(purrr,map) diff --git a/R/appdir.R b/R/appdir.R index 9e9a346..af1d768 100644 --- a/R/appdir.R +++ b/R/appdir.R @@ -1,6 +1,9 @@ #' Remove all cache files #' -#' @description Remove all package cache files. +#' @description +#' `r lifecycle::badge("experimental")` +#' +#' Remove all package cache files. #' @importFrom utils askYesNo #' @examples #' if (interactive()) diff --git a/R/ggplot2_scales.R b/R/ggplot2_scales.R index f6293d8..c279e07 100644 --- a/R/ggplot2_scales.R +++ b/R/ggplot2_scales.R @@ -1,4 +1,8 @@ #' Scales to use for ggplot2 +#' +#' @description +#' `r lifecycle::badge("experimental")` +#' #' @param type Display item #' @param ... Arguments to pass on to [ggplot2::scale_color_gradientn] or #' [ggplot2::scale_fill_gradientn] diff --git a/R/jma_collect.R b/R/jma_collect.R index 854dbe5..b55800f 100644 --- a/R/jma_collect.R +++ b/R/jma_collect.R @@ -1,6 +1,8 @@ #' Collect JMA Historical Weather Data #' #' @description +#' `r lifecycle::badge("stable")` +#' #' Refer to the data available in the JMA Historical Weather Data Search. #' Executed by specifying the target location and date. #' Currently, not all types of data acquisition are supported. diff --git a/R/jmastats-package.R b/R/jmastats-package.R new file mode 100644 index 0000000..425b3c1 --- /dev/null +++ b/R/jmastats-package.R @@ -0,0 +1,7 @@ +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +#' @importFrom lifecycle deprecated +## usethis namespace: end +NULL diff --git a/R/jmastats.R b/R/jmastats.R deleted file mode 100644 index 3c20e1f..0000000 --- a/R/jmastats.R +++ /dev/null @@ -1,7 +0,0 @@ -#' Access to Japan Meteorological Agency Data -#' -#' @docType package -#' @description Provides the features to download weather data published -#' by the Japan Meteorological Agency website (). -#' @name jmastats -NULL diff --git a/R/kishou_feed.R b/R/kishou_feed.R index 0071f22..8cd3dc1 100644 --- a/R/kishou_feed.R +++ b/R/kishou_feed.R @@ -1,4 +1,7 @@ #' Read Kishou Disaster Prevention Information Feed +#' +#' @description +#' `r lifecycle::badge("experimental")` #' @param frequency Release frequency. Select either high frequency ("high") or #' long term ("low") #' @param type Feed type. Specify the item to be retrieved as a string. diff --git a/R/nearest_station.R b/R/nearest_station.R index c132af7..f369dcb 100644 --- a/R/nearest_station.R +++ b/R/nearest_station.R @@ -1,14 +1,15 @@ #' Find out neighborhood stations #' -#' @description Return the nearest [stations] information -#' to the given coordinates. +#' @description +#' `r lifecycle::badge("stable")` +#' +#' Return the nearest [stations] information to the given coordinates. #' #' @details #' * `nearest_station()`: Return single station data. #' * `pick_neighbor_stations()`: Pick-up neighbourhood stations. #' * `pick_neighbor_tide_stations()`: Pick-up neighbourhood tidal observation stations. #' Filter by distance from target point. -#' @return sf #' @param longitude Longitude. #' @param latitude Latitude. #' @param geometry XY [sf::sf] object. diff --git a/R/parse_unit.R b/R/parse_unit.R index 1644e36..81a40ac 100644 --- a/R/parse_unit.R +++ b/R/parse_unit.R @@ -1,5 +1,8 @@ #' Parse data variable units #' +#' @description +#' `r lifecycle::badge("stable")` +#' #' @param data data #' @param rename *logical* #' @importFrom dplyr bind_cols select diff --git a/R/pivot_tide_level.R b/R/pivot_tide_level.R index 359c101..f7e1b20 100644 --- a/R/pivot_tide_level.R +++ b/R/pivot_tide_level.R @@ -1,5 +1,8 @@ #' Convert and split tidal level data #' +#' @description +#' `r lifecycle::badge("stable")` +#' #' @param data tidal level data #' @examples #' \donttest{ diff --git a/R/read_eqdb.R b/R/read_eqdb.R index 471a60c..ed9748f 100644 --- a/R/read_eqdb.R +++ b/R/read_eqdb.R @@ -1,4 +1,7 @@ #' Read the csv of the earthquake database +#' +#' @description +#' `r lifecycle::badge("stable")` #' @param path local file path to earthquake record file. #' @param show_metadata logical. If *FALSE*, returns only the values #' observed at each location. diff --git a/R/read_jma_weather.R b/R/read_jma_weather.R index 559fdcf..485b986 100644 --- a/R/read_jma_weather.R +++ b/R/read_jma_weather.R @@ -1,5 +1,8 @@ #' Read the past weather -#' @description Read the past weather data files downloaded from JMA. +#' @description +#' `r lifecycle::badge("experimental")` +#' +#' Read the past weather data files downloaded from JMA. #' @param path The path to the downloaded file. #' @seealso , #' diff --git a/R/read_tide_level.R b/R/read_tide_level.R index f596d47..fc487e5 100644 --- a/R/read_tide_level.R +++ b/R/read_tide_level.R @@ -1,5 +1,8 @@ #' Read and parse tide level text data #' +#' @description +#' `r lifecycle::badge("stable")` +#' #' @param path URL or local file path to sea tide level file #' @param .year A.D. 1997 to present year. #' @param .month Month number. 1997 only, valid after March. diff --git a/R/track.R b/R/track.R index 579be0e..761501a 100644 --- a/R/track.R +++ b/R/track.R @@ -1,6 +1,9 @@ #' Read RSMC Tokyo-Typhoon Center's best track data #' -#' @description Tidy formatting best track data and combine each point to line. +#' @description +#' `r lifecycle::badge("stable")` +#' +#' Tidy formatting best track data and combine each point to line. #' @details #' * `read_rsmc_besttrack()`: Read single best track data into [sf][sf::st_sf] #' contains observation record as point. diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 0000000..745ab0c --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 0000000..d5c9559 --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 0000000..b61c57c --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg new file mode 100644 index 0000000..5d88fc2 --- /dev/null +++ b/man/figures/lifecycle-experimental.svg @@ -0,0 +1,21 @@ + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 0000000..897370e --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 0000000..7c1721d --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 0000000..9c166ff --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 0000000..9bf21e7 --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 0000000..db8d757 --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/ggplot2-scales.Rd b/man/ggplot2-scales.Rd index 4fe74ac..c84960f 100644 --- a/man/ggplot2-scales.Rd +++ b/man/ggplot2-scales.Rd @@ -24,11 +24,9 @@ scale_fill_jma_relative(type = "amedas", ...) } \value{ A \code{ScaleContinuous} object that can be added to a \code{ggplot} object - -gg scale object } \description{ -Scales to use for ggplot2 +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ \donttest{ diff --git a/man/jma_collect.Rd b/man/jma_collect.Rd index 8469576..6475bbc 100644 --- a/man/jma_collect.Rd +++ b/man/jma_collect.Rd @@ -42,6 +42,8 @@ for some reason. (\code{TRUE}, the default)} a \code{tbl} object } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} + Refer to the data available in the JMA Historical Weather Data Search. Executed by specifying the target location and date. Currently, not all types of data acquisition are supported. diff --git a/man/jmastats-package.Rd b/man/jmastats-package.Rd new file mode 100644 index 0000000..50cfb47 --- /dev/null +++ b/man/jmastats-package.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/jmastats-package.R +\docType{package} +\name{jmastats-package} +\alias{jmastats} +\alias{jmastats-package} +\title{jmastats: Download Weather Data from Japan Meteorological Agency Website} +\description{ +\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} + +Provides features that allow users to download weather data published by the Japan Meteorological Agency (JMA) website (\url{https://www.jma.go.jp/jma/index.html}). The data includes information dating back to 1976 and aligns with the categories available on the website. Additionally, users can process the best track data of typhoons and easily handle earthquake record files. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/uribo/jmastats} + \item Report bugs at \url{https://github.com/uribo/jmastats/issues} +} + +} +\author{ +\strong{Maintainer}: Shinya Uryu \email{suika1127@gmail.com} (\href{https://orcid.org/0000-0002-0493-6186}{ORCID}) [copyright holder] + +} +\keyword{internal} diff --git a/man/jmastats.Rd b/man/jmastats.Rd deleted file mode 100644 index 7050672..0000000 --- a/man/jmastats.Rd +++ /dev/null @@ -1,10 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/jmastats.R -\docType{package} -\name{jmastats} -\alias{jmastats} -\title{Access to Japan Meteorological Agency Data} -\description{ -Provides the features to download weather data published -by the Japan Meteorological Agency website (\url{https://www.data.jma.go.jp/obd/stats/etrn/index.php}). -} diff --git a/man/nearest_station.Rd b/man/nearest_station.Rd index a3baa0c..54940a7 100644 --- a/man/nearest_station.Rd +++ b/man/nearest_station.Rd @@ -40,11 +40,12 @@ This value is passed to \link[units:units]{units::as_units}.} \item{year}{For tide level data. Restricted to the observation points in the target year.} } \value{ -sf +an object of class \code{sf}. } \description{ -Return the nearest \link{stations} information -to the given coordinates. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} + +Return the nearest \link{stations} information to the given coordinates. } \details{ \itemize{ diff --git a/man/parse_unit.Rd b/man/parse_unit.Rd index f93533b..0a78641 100644 --- a/man/parse_unit.Rd +++ b/man/parse_unit.Rd @@ -15,7 +15,7 @@ parse_unit(data, rename = TRUE) a \code{tbl} object } \description{ -Parse data variable units +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} } \examples{ jma_collect("hourly", "0010", 2018, 7, 30) |> diff --git a/man/pivot_tide_level.Rd b/man/pivot_tide_level.Rd index a5ed04f..68ff904 100644 --- a/man/pivot_tide_level.Rd +++ b/man/pivot_tide_level.Rd @@ -13,7 +13,7 @@ pivot_tide_level(data) List to store two datasets containing hourly and tide level data. } \description{ -Convert and split tidal level data +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} } \examples{ \donttest{ diff --git a/man/read_eqdb_csv.Rd b/man/read_eqdb_csv.Rd index 369987f..2d09fcf 100644 --- a/man/read_eqdb_csv.Rd +++ b/man/read_eqdb_csv.Rd @@ -16,7 +16,7 @@ observed at each location.} a \code{tbl} object } \description{ -Read the csv of the earthquake database +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} } \examples{ read_eqdb_csv(system.file("dummy/eqdb.csv", package = "jmastats")) diff --git a/man/read_jma_weather.Rd b/man/read_jma_weather.Rd index e116086..4249cef 100644 --- a/man/read_jma_weather.Rd +++ b/man/read_jma_weather.Rd @@ -13,6 +13,8 @@ read_jma_weather(path) a \code{tbl} object } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + Read the past weather data files downloaded from JMA. } \examples{ diff --git a/man/read_kishou_feed.Rd b/man/read_kishou_feed.Rd index 3391a01..1fdc2c3 100644 --- a/man/read_kishou_feed.Rd +++ b/man/read_kishou_feed.Rd @@ -17,7 +17,7 @@ See details for the items.} a \code{tbl} object } \description{ -Read Kishou Disaster Prevention Information Feed +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \details{ The following items can be specified in the type argument. diff --git a/man/read_tide_level.Rd b/man/read_tide_level.Rd index 1837d94..16cc414 100644 --- a/man/read_tide_level.Rd +++ b/man/read_tide_level.Rd @@ -21,7 +21,7 @@ read_tide_level(path = NULL, .year, .month, .stn, raw = FALSE) a \code{tbl} object } \description{ -Read and parse tide level text data +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} } \examples{ \donttest{ diff --git a/man/reset_cache.Rd b/man/reset_cache.Rd index 59e7b2f..53ac575 100644 --- a/man/reset_cache.Rd +++ b/man/reset_cache.Rd @@ -10,6 +10,8 @@ reset_cache() None } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + Remove all package cache files. } \examples{ diff --git a/man/track.Rd b/man/track.Rd index 73dab2e..a417523 100644 --- a/man/track.Rd +++ b/man/track.Rd @@ -30,6 +30,8 @@ in the user's computer or the URL.} a \code{tbl} object } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} + Tidy formatting best track data and combine each point to line. } \details{ From 1fc0a084326f4cde00c9a3676c428fd0095a350d Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Fri, 8 Sep 2023 11:09:16 +0900 Subject: [PATCH 13/17] [fix]cran comment --- R/appdir.R | 6 ++---- R/ggplot2_scales.R | 9 ++++++--- R/nearest_station.R | 1 + R/parse_unit.R | 9 +++++++-- cran-comments.md | 3 ++- man/ggplot2-scales.Rd | 8 ++++++-- man/parse_unit.Rd | 9 +++++++-- tests/testthat/test-nearest_station.R | 1 + 8 files changed, 32 insertions(+), 14 deletions(-) diff --git a/R/appdir.R b/R/appdir.R index af1d768..5fdb16c 100644 --- a/R/appdir.R +++ b/R/appdir.R @@ -31,10 +31,8 @@ pick_out_cache <- function(item = NULL, } search_cache_file <- function(item, station_type, param) { - cache_dir <- rappdirs::user_cache_dir("jmastats") - if (!file.exists(cache_dir)) { - dir.create(cache_dir, recursive = TRUE) - } + cache_dir <- + rappdirs::user_cache_dir("jmastats") file.path( cache_dir, paste0(item, "_", diff --git a/R/ggplot2_scales.R b/R/ggplot2_scales.R index c279e07..c0e16e7 100644 --- a/R/ggplot2_scales.R +++ b/R/ggplot2_scales.R @@ -12,9 +12,13 @@ #' @rdname ggplot2-scales #' @examples #' \donttest{ +#' # d <- +#' # jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> +#' # parse_unit() #' d <- -#' jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> -#' parse_unit() +#' data.frame( +#' date = as.Date(c(17410, 17411, 17412, 17413, 17414, 17415)), +#' precipitation_sum = units::set_units(c(3.5, 9.5, 0, 0, 0, 5), "mm")) #' #' library(ggplot2) #' library(units) @@ -26,7 +30,6 @@ #' scale_fill_jma_absolute(type = "precipitation") #' } #' @export -#' @return gg scale object scale_color_jma_absolute <- function(type = "precipitation", ...) { pal <- diff --git a/R/nearest_station.R b/R/nearest_station.R index f369dcb..4b9e265 100644 --- a/R/nearest_station.R +++ b/R/nearest_station.R @@ -44,6 +44,7 @@ NULL area <- distance <- NULL #' @rdname nearest_station +#' @return an object of class `sf`. #' @export nearest_station <- function(longitude, latitude, geometry = NULL) { coords <- diff --git a/R/parse_unit.R b/R/parse_unit.R index 81a40ac..93eaa96 100644 --- a/R/parse_unit.R +++ b/R/parse_unit.R @@ -11,8 +11,13 @@ #' @importFrom tidyselect all_of where #' @importFrom units as_units #' @examples -#' jma_collect("hourly", "0010", 2018, 7, 30) |> -#' parse_unit(rename = TRUE) +#' # d <- jma_collect("hourly", "0010", 2018, 7, 30) +#' d <- +#' tibble::tibble(date = as.Date(c(17742, 17742, 17742, 17742, 17742, 17742)), +#' time = c(1, 2, 3, 4, 5, 6), +#' `precipitation(mm)` = c(0, 0, 0, 0, 0, 0), +#' `temperature(℃)` = c(22.4, 22.1, 21, 20.2, 20.4, 23.5)) +#' d |> parse_unit(rename = TRUE) #' @export #' @return a `tbl` object parse_unit <- function(data, rename = TRUE) { diff --git a/cran-comments.md b/cran-comments.md index 9255ba1..f87de59 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -9,8 +9,9 @@ 0 errors | 0 warnings | 3 note -* This is a new release. +* This is a new release (re-submit). * Remove `VignetteBuilder` filed in DESCRIPTION. +* Removed functions and example handling of the user's home file space. * checking data for non-ASCII characters ... NOTE Note: found 16726 marked UTF-8 strings * checking CRAN incoming feasibility ... [18s] NOTE diff --git a/man/ggplot2-scales.Rd b/man/ggplot2-scales.Rd index c84960f..32af469 100644 --- a/man/ggplot2-scales.Rd +++ b/man/ggplot2-scales.Rd @@ -30,9 +30,13 @@ A \code{ScaleContinuous} object that can be added to a \code{ggplot} object } \examples{ \donttest{ +# d <- +# jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> +# parse_unit() d <- -jma_collect("daily", block_no = "47646", year = 2017, month = 9, pack = FALSE) |> -parse_unit() +data.frame( + date = as.Date(c(17410, 17411, 17412, 17413, 17414, 17415)), + precipitation_sum = units::set_units(c(3.5, 9.5, 0, 0, 0, 5), "mm")) library(ggplot2) library(units) diff --git a/man/parse_unit.Rd b/man/parse_unit.Rd index 0a78641..952ca2e 100644 --- a/man/parse_unit.Rd +++ b/man/parse_unit.Rd @@ -18,6 +18,11 @@ a \code{tbl} object \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} } \examples{ -jma_collect("hourly", "0010", 2018, 7, 30) |> - parse_unit(rename = TRUE) +# d <- jma_collect("hourly", "0010", 2018, 7, 30) +d <- +tibble::tibble(date = as.Date(c(17742, 17742, 17742, 17742, 17742, 17742)), + time = c(1, 2, 3, 4, 5, 6), + `precipitation(mm)` = c(0, 0, 0, 0, 0, 0), + `temperature(℃)` = c(22.4, 22.1, 21, 20.2, 20.4, 23.5)) +d |> parse_unit(rename = TRUE) } diff --git a/tests/testthat/test-nearest_station.R b/tests/testthat/test-nearest_station.R index 5e1b3f5..0407274 100644 --- a/tests/testthat/test-nearest_station.R +++ b/tests/testthat/test-nearest_station.R @@ -70,6 +70,7 @@ test_that("multiplication works", { }) test_that("failed", { + skip_if_not_installed("lwgeom") expect_message( nearest_station(longitude = 60, latitude = 30.4) ) From 38ac046c79e6847dcf14136bc5b02c56d9cf8741 Mon Sep 17 00:00:00 2001 From: Shinya Uryu Date: Sun, 10 Sep 2023 21:23:26 +0900 Subject: [PATCH 14/17] =?UTF-8?q?[modify]=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E4=BE=8B=E3=82=92=E7=A4=BA=E3=81=99=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AE=E3=83=80=E3=83=9F=E3=83=BC=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=81=AE=E7=94=A8=E6=84=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/pivot_tide_level.R | 4 +--- R/read_tide_level.R | 11 ++++++----- README.Rmd | 11 ++++++++++- README.md | 27 ++++++++++++++++++++++++++- inst/dummy/tide.txt | 1 + man/pivot_tide_level.Rd | 4 +--- man/read_tide_level.Rd | 11 ++++++----- 7 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 inst/dummy/tide.txt diff --git a/R/pivot_tide_level.R b/R/pivot_tide_level.R index f7e1b20..267b69d 100644 --- a/R/pivot_tide_level.R +++ b/R/pivot_tide_level.R @@ -5,10 +5,8 @@ #' #' @param data tidal level data #' @examples -#' \donttest{ -#' read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") |> +#' read_tide_level(system.file("dummy/tide.txt", package = "jmastats")) |> #' pivot_tide_level() -#' } #' @seealso [read_tide_level()] #' @return List to store two datasets containing hourly and tide level data. #' @export diff --git a/R/read_tide_level.R b/R/read_tide_level.R index fc487e5..5c19a21 100644 --- a/R/read_tide_level.R +++ b/R/read_tide_level.R @@ -10,11 +10,12 @@ #' @param raw If *TRUE*, return raw format data #' @seealso #' @examples -#' \donttest{ -#' read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") -#' -#' read_tide_level(.year = 2020, .month = 2, .stn = "TK") -#' } +#' # Read a local storage file (dummy data) +#' read_tide_level(system.file("dummy/tide.txt", package = "jmastats")) +#' # Request from URL +#' # read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") +#' # Request from parameters +#' # read_tide_level(.year = 2020, .month = 2, .stn = "TK") #' @export #' @return a `tbl` object read_tide_level <- function(path = NULL, .year, .month, .stn, raw = FALSE) { diff --git a/README.Rmd b/README.Rmd index 02a8ef2..e6b7246 100644 --- a/README.Rmd +++ b/README.Rmd @@ -113,12 +113,21 @@ read_kishou_feed("low", "other") ### 潮汐観測資料 + ```{r} +# URLを指定しての読み込み read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") - +# URLを構成するパラメータを指定した読み込み read_tide_level(.year = 2020, .month = 2, .stn = "TK") ``` +```{r} +#| eval: true +# ローカルに保存したファイルの読み込み(パスを指定) +read_tide_level(system.file("dummy/tide.txt", package = "jmastats")) +``` + + ### 震度データベース [震度データベース検索](https://www.data.jma.go.jp/svd/eqdb/data/shindo/index.html)よりダウンロードしたcscvファイルを読み込む関数として`read_eqdb_csv()`があります。ダミーデータを読み込む例を示します。 diff --git a/README.md b/README.md index 85787eb..8875ddb 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,36 @@ read_kishou_feed("low", "other") ### 潮汐観測資料 ``` r +# URLを指定しての読み込み read_tide_level("https://www.data.jma.go.jp/gmd/kaiyou/data/db/tide/suisan/txt/2020/TK.txt") - +# URLを構成するパラメータを指定した読み込み read_tide_level(.year = 2020, .month = 2, .stn = "TK") ``` +``` r +# ローカルに保存したファイルの読み込み(パスを指定) +read_tide_level(system.file("dummy/tide.txt", package = "jmastats")) +#> New names: +#> New names: +#> New names: +#> New names: +#> • `hm` -> `hm...1` +#> • `hm` -> `hm...2` +#> • `hm` -> `hm...3` +#> • `hm` -> `hm...4` +#> # A tibble: 1 × 42 +#> hry_00 hry_01 hry_02 hry_03 hry_04 hry_05 hry_06 hry_07 hry_08 hry_09 hry_10 +#> [cm] [cm] [cm] [cm] [cm] [cm] [cm] [cm] [cm] [cm] [cm] +#> 1 128 127 122 115 107 102 101 106 117 132 146 +#> # ℹ 31 more variables: hry_11 [cm], hry_12 [cm], hry_13 [cm], hry_14 [cm], +#> # hry_15 [cm], hry_16 [cm], hry_17 [cm], hry_18 [cm], hry_19 [cm], +#> # hry_20 [cm], hry_21 [cm], hry_22 [cm], hry_23 [cm], date , stn , +#> # low_tide_hm_obs1