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

Allow R developers to have multiple R folders inside an R package

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

feddelegrand7/rfold

Repository files navigation

CRAN statusmetacran downloadsmetacran downloads

An introductory video can be foundhere

The goal of therfold package is to allowR developers to work withmanyR directories within anR package. A considerable limitationregardingR packages development, is that one cannot create otherdirectories/sub directories (other than theR directory) and bind themto the package ecosystem.

Usingrfold, you can create as many directories/sub directories(outside of yourR directory).

Therfold() function will list all the.R scripts available outsideof theR folder, assign their names to.Rbuildignore file andtransfer them within the mainR directory, giving you all theflexibility you need to organize your package into manydirectories/sub-directories.

Working withtest files

Usingrfold, you can arrange your test file the way you want, you canfor example put your test and R scripts in one folder. To do so, youneed to append thetest- word to the name of your test files. Forexample,test-myapi.R. This wayrfold will recognize it as a testfile and move it within the correct folder.

At the moment,rfold works only with thetestthat framework, feelfree to open an issue if other test framework should be supported

Installation

You can install the development version ofrfold with:

install.packages("rfold")

Usage

Just userfold::rfold() before building or documenting your packageand you’re all set. If you’re tired of runningrfold::rfold(), thendevtools::load_all() each time, you can create a function that doesboth, for example:

rfold_load_all<-function() {rfold::rfold()devtools::load_all()}

This way, you’ll be sure to work with the last state of your package.

Example

Suppose that within this package, I would decide to have the followingstructure:

fs::dir_tree()
## .## +-- api## |   +-- api_call.R## |   \-- test-api_call.R## +-- DESCRIPTION## +-- main## |   +-- main1.R## |   +-- main2.R## |   \-- test-main## |       +-- test-file1.R## |       \-- test-file2.R## +-- man## +-- NAMESPACE## +-- R## +-- README.md## +-- README.Rmd## +-- rfoldtester.Rproj## +-- tests## |   +-- testthat## |   \-- testthat.R## \-- utilities##     +-- test-utils1.R##     +-- test-utils2.R##     +-- utils1.R##     \-- utils2.R

Runningrfold::rfold(), all the external (external to theR folder).R scripts will be moved within theR ortests folder, dependingon the type of file (note that if thetests folder is not available,rfold will create it for you):

rfold::rfold()
## v Setting active project to 'C:/Users/Administrateur/Desktop/rfoldtester'i Copying the following R files with prefix 'DO_NOT_EDIT_' into the R folder: api/api_call.R, main/main1.R, main/main2.R, utilities/utils1.R, utilities/utils2.R## i Copying the following tests files with prefix 'DO_NOT_EDIT_' into the tests/testthat folder: api/test-api_call.R, main/test-main/test-file1.R, main/test-main/test-file2.R, utilities/test-utils1.R, utilities/test-utils2.R

As such, we will get now the following structure:

fs::dir_tree()
## .## +-- api## |   +-- api_call.R## |   \-- test-api_call.R## +-- DESCRIPTION## +-- main## |   +-- main1.R## |   +-- main2.R## |   \-- test-main## |       +-- test-file1.R## |       \-- test-file2.R## +-- man## +-- NAMESPACE## +-- R## |   +-- DO_NOT_EDIT_api_call.R## |   +-- DO_NOT_EDIT_main1.R## |   +-- DO_NOT_EDIT_main2.R## |   +-- DO_NOT_EDIT_utils1.R## |   \-- DO_NOT_EDIT_utils2.R## +-- README.md## +-- README.Rmd## +-- rfoldtester.Rproj## +-- tests## |   +-- testthat## |   |   +-- test-DO_NOT_EDIT_api_call.R## |   |   +-- test-DO_NOT_EDIT_file1.R## |   |   +-- test-DO_NOT_EDIT_file2.R## |   |   +-- test-DO_NOT_EDIT_utils1.R## |   |   \-- test-DO_NOT_EDIT_utils2.R## |   \-- testthat.R## \-- utilities##     +-- test-utils1.R##     +-- test-utils2.R##     +-- utils1.R##     \-- utils2.R

Notice, that script names that will be transferred to theR folderhave their name prefixed with the characterDO_NOT_EDIT. You can tweakthis feature or deactivate it using thescript_name_prefix parameterof therfold() function. Concerning thetest file, they have tostart withtest- word in order to be tested, as such, thescript_name_prefix will be appended after thetest- part.

The following comment will also be inserted at the top of each scriptthat will be moved withrfold:# GENERATED BY FOLD: DO NOT EDIT BYHAND ####

There’s another parameter available, calledfolders_to_ignore whichallows you to ignore certain directories (for exampledev directory)when running therfold function.

Note also thatdevtools::build() anddevtools::document() will onlyconsider the scripts available within yourR folder.

Code of Conduct

Please note that the rfold project is released with aContributor CodeofConduct.By contributing to this project, you agree to abide by its terms.

About

Allow R developers to have multiple R folders inside an R package

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp