Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2019年版Rパッケージ開発の手引き / pkg_dev

Uryu Shinya
November 16, 2019

2019年版Rパッケージ開発の手引き / pkg_dev

Uryu Shinya

November 16, 2019
Tweet

More Decks by Uryu Shinya

Other Decks in Programming

Transcript

  1. ࢲʹ͍ͭͯ CRAN 5 + (1) GitHub 20+ \TG^ UJEZWFSTF SMJCܥͷύοέʔδ΁ͷ$POUSJCVUJPO

    Ἒ৓ݝͭ͘͹ࢢ͔Βདྷ·ͨ͠ʢผ෎ࢢ͸౓໨ʣ >1000 km 1SJWBUFؚΉ
  2. ୭ɾԿͷͨΊͷύοέʔδʁ ଞऀ ࣗ෼ࣗ਎ͷ ࣌ؒͷઅ໿ ڞ༗ ίϛϡχςΟ ٕज़ଅਐ ྫ͑͹ {magrittr} %>%

    {rlang} !!,quo() ڞಉ࡞ۀऀ΍ୈࡾऀͷ ख఻͍ͱͳΔΑ͏ʹ ʢࣗ෼͕ͦ͏Ͱ͋ΔΑ͏ʹʣ
  3. ύοέʔδͱ͸Կ͔ جຊతͳύοέʔδʢιʔεύοέʔδʣͷߏ੒ R data man tests .R .R .Rd .Rd

    .rds Rout.save ΍ .R .Rbuildignore DESCRIPTION LICENSE NEWS README vignettes src inst data-raw ඞཁʹԠͯ͡ ϑΥϧμΛ ഑ஔ ༨ܭͳϑΝΠϧ͕͋Δͱ DIFDLͰౖΒΕΔ
  4. ύοέʔδ։ൃ·ͰͷྲྀΕ Ұྫ ಈػ෇͚ طଘͷύοέʔδ͕͋Δʁ ࣮૷͸ΠέͯΔʁ վળ఺͸ͳ͍͔ʁ YES NO ؔ਺ͷ࣮૷͸Մೳʁ *TTVFʹه࿥

    13ΛૹΔ 044ͱͯ͠ެ։ʁ ύοέʔδ໊Λߟ͑Δ create_package() Մจࣈɺ਺ࣈɺϐϦΦυ ઌ಄͸จࣈͰ࢝·Δ͜ͱɺ ຤ඌʹϐϦΦυ͸࢖͑ͳ͍
  5. ύοέʔδ։ൃ·ͰͷྲྀΕ Ұྫ YES NO ؔ਺Λॻ͘ υΩϡϝϯτΛ੔උ͢Δ ςετίʔυΛ༻ҙ͢Δ ίʔυΛચ࿅ͤ͞Δ ςετɺνΣοΫΛ௨͢ $3"/ొ࿥Λ໨ࢦ͢

    ࠓ೔͸࿩͠·ͤΜ test(),check() Ϗϧυͯ͠ڞ༗ɺ044Ͱެ։ (JU)VC͕ओྲྀ ଞʹ(JU-BC΍#JCVDLFUͳͲ build(),install()
  6. %&4$3*15*0/ΛຒΊΑ͏ %&4$3*15*0/ͷ৘ใ͕ $3"/ʹ൓ө͞Ε·͢ Package: spatech Title: What the Package Does

    (One Line, Title Case) Version: 0.0.0.9000 Authors@R: person(given = "First", family = "Last", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "YOUR-ORCID-ID")) Description: What the package does (one paragraph). License: What license it uses Encoding: UTF-8 LazyData: true
  7. %&4$3*15*0/ΛຒΊΑ͏ Package: spatech Title: Oita Spa Tech Sample Version: 0.0.0.9000

    Authors@R: person(given = "Shinya", family = "Uryu", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-0493-6186")) Description: Guide to first R library development. License: MIT + file LICENSE Encoding: UTF-8 LazyData: true URL: https: //github.com/uribo/spatech BugReports: https: //github.com/uribo/spatech/issues use_github() use_mit_license() .Rprofile ʹઃఆΛهड़͓ͯ͘͠ͱָ author creator contributor copyright holder ։ൃʹܞΘΔਓͷϦετ ?person ৄࡉ͸
  8. ςετʹ͸ԿΛॻ͘ʁ ίʔυ͕ͲͷΑ͏ʹৼΔ෣͏ͷ͔ɺ༧૝͞ΕΔ݁ՌΛهड़͢Δ expect_message( hello_msg(name = "uribo")) expect_warning( hello_msg()) expect_equal( hello_msg(name

    = "uribo"), "Hi, uribo") #> Hi, uribo #> Error: hello_msg(name = "uribo") not equal to "Hi, uribo". #> target is NULL, current is character .R test-msg.R ؔ਺ͷڍಈΛ஌ΔͨΊʹ΋ UFTUͷϑΝΠϧΛݟΔͷ͸ ྑ͍
  9. SPYZHFOίϝϯτ !UBHͷܗࣜ `Ͱ࢝·Γɺର৅ͷؔ਺ͷલʹهड़͢Δ @inheritParams @rdname @export {roxygen2md} {roxygen2} ॏཁͳ΋ͷ @param

    @description SPYZHFOλά·ͱΊc"UVTZTCMPH https://blog.atusy.net/2018/08/28/roxygen2matome/ SPYZHFOίϝϯτʹNBSLEPXOه๏ ΛՄೳʹ͢Δʢ3EϑΝΠϧੜ੒࣌ʹม׵ʣ ؔ਺ͷΤΫεϙʔτ Ҿ਺ͷܧঝ
  10. #' @title Read and Parse Fundamental Geospatial Data (FGD) file

    #' #' @description The JPGIS (GML) format file provided by FGD as input, #' the fundamental items in the file is read as an 'sf' object. #' Supporting FGD Version 4.1 (2016/10/31). #' @details Support following items: #' Administrative Area ('AdmArea'), Administrative Boundary ('AdmBdry'), #’ … লུ #' @seealso \url{https: //fgd.gsi.go.jp/download/ref_kihon.html} #' @param file Path to XML file #' @import sf #' @import xml2 #' @importFrom purrr pmap reduce list_modify #' @importFrom tibble new_tibble #' @return A [sf][sf ::st_sf] #' @export #' @examples #' # Administrative Area #' read_fgd(system.file("extdata/FG-GML-000000-AdmPt-dummy.xml", package = "fgdr")) ?fgdr ::read_fgd()