pak::pak("maple60/jpplantnames")
remotes::install_github("maple60/jpplantnames")
# renv::install("maple60/jpplantnames") # renvを使用している場合jpplantnames Rパッケージについて
最近作成した、jpplantnamesというRパッケージについて簡単にまとめます。 ドキュメントは、以下をご覧ください。
インストールとライブラリの読み込み
いつも通りパッケージをインストールします。 現在はGitHubにしか公開していませんので、pakやremotes, renvなどを使ってインストールしてください。
インストールが完了したら、library()で読み込みます。
和名から学名を取得する
scientific_name()関数で和名から学名を取得できます。 初回の実行はデータのダウンロードが行われるため、少し時間がかかります。 この時、インターネットに接続されている必要があることに注意します。 二回目以降は、キャッシュが使用されるため、すぐに結果が返ってきます。
scientific_name("コナラ")If you also want author information, set with_author = TRUE.
scientific_name("コナラ", with_author = TRUE)You can also pass a vector when you want to retrieve scientific names for multiple Japanese names at once.
scientific_name(c("コナラ", "アカマツ", "イチョウ"))Getting a Japanese Name from a Scientific Name
Use japanese_name_search() when you want to retrieve Japanese names from a scientific name.
japanese_name_search("Quercus serrata", field = "scientific")In this search, all records whose scientific name contains "Quercus serrata" are returned. If you want Japanese names that exactly match a specific scientific name, set exact = TRUE.
japanese_name_search("Quercus serrata", field = "scientific", exact = TRUE)Even with exact matching, multiple records may be returned. This happens because multiple Japanese names and aliases may be registered for the same species, such as Konara.
Searching for Ambiguous Japanese Names
When field notes are digitized, typos may appear in Japanese plant names. For example, "コナラ" might accidentally be entered as "コラナ". In such cases, you can use japanese_name_suggest() to search for likely correct Japanese names from an ambiguous input.
japanese_name_suggest("コラナ")Another possible typo is entering "タロヨウ" instead of "タラヨウ".
japanese_name_suggest("タロヨウ")This fuzzy search compares the entered Japanese name with Japanese names in the checklist and calculates a string distance for each candidate. In the current implementation, when the stringdist package is available, it uses stringdist::stringdist() with method = "osa". osa means Optimal String Alignment distance, or restricted Damerau-Levenshtein distance, which considers adjacent character transpositions in addition to insertions, deletions, and substitutions. This makes it possible to suggest close candidates for Japanese names that include simple typos or swapped character order.
Matching Scientific Names Against GBIF
You can match scientific names against GBIF (Global Biodiversity Information Facility) with gbif_match().
gbif_match("Quercus serrata")Matching Scientific Names Against WFO
You can also match scientific names against another database, WFO (World Flora Online).
wfo_accepted_name("Quercus serrata")Use wfo_suggest() when you want to search by partial match.
wfo_suggest("Quercus serrata")Getting Species Information from a Japanese Name
You can also retrieve species-related information from a Japanese name. Use japanese_name_info() for this. It is usually convenient to store the result in a variable. Printing the object gives a short summary.
jp_info <- japanese_name_info("コナラ")
print(jp_info)This is a short report saying that the Japanese name "コナラ" matched Quercus serrata Murray in the checklist and had 9 candidate rows.
The object is a list, so you can access detailed information with $. Use $summary to expand the short report as a data frame.
jp_info$summaryUse $japanese_name to expand the Japanese-name information as a data frame.
jp_info$japanese_nameIf you want to compare the result with GBIF or WFO data, set wfo = TRUE or gbif = TRUE.
jp_info <- japanese_name_info("コナラ", wfo = TRUE, gbif = TRUE)
jp_info$wfo
jp_info$gbifIn short, japanese_name_info is a helper that brings together the functions introduced above.