All Projects → ThinkR-open → fusen

ThinkR-open / fusen

Licence: other
Inflate your package from a simple flat Rmd

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to fusen

LiteOTP
Multi OTP Spam Amp/Paralell threads
Stars: ✭ 50 (-49.49%)
Mutual labels:  package
sound field analysis-py
Analyze, visualize and process sound field data recorded by spherical microphone arrays.
Stars: ✭ 61 (-38.38%)
Mutual labels:  package
create-npm-package
Creates an npm package boilerplate that you don't have to write again 📦
Stars: ✭ 21 (-78.79%)
Mutual labels:  package
normalize-pkg
Normalize values in package.json to improve compatibility, programmatic readability and usefulness with third party libs.
Stars: ✭ 18 (-81.82%)
Mutual labels:  package
action-autotag
Automatically generate a new tag when the manifest file (package.json, Dockerfile, custom file, etc) version changes.
Stars: ✭ 45 (-54.55%)
Mutual labels:  package
Ragnarok
Virus Package ( For Educational Purposes )
Stars: ✭ 23 (-76.77%)
Mutual labels:  package
angular-package-builder
[DEPRECATED] Packages your Angular 4+ library based on the Angular Package Format.
Stars: ✭ 25 (-74.75%)
Mutual labels:  package
caption-core
Caption Core acts as an abstraction layer for Caption’s core functionality.
Stars: ✭ 33 (-66.67%)
Mutual labels:  package
pidesktop
Collected files, drivers and documentation for the pidesktop case
Stars: ✭ 26 (-73.74%)
Mutual labels:  package
menu button
Flutter plugin to display a popup menu button widget with handsome design and easy to use.
Stars: ✭ 64 (-35.35%)
Mutual labels:  package
ReplAPI.it-NodeJS
[DEPRECIATED] 𝙀𝙫𝙚𝙧𝙮𝙩𝙝𝙞𝙣𝙜 𝙍𝙚𝙥𝙡𝙞𝙩, 𝙖𝙡𝙡 𝙖𝙩 𝙮𝙤𝙪𝙧 𝙙𝙞𝙨𝙥𝙤𝙨𝙖𝙡. This is the single most extensive Replit package, allowing you to access various parts of the site with just a few classes and methods. Maintained by @RayhanADev.
Stars: ✭ 32 (-67.68%)
Mutual labels:  package
Arch-Data-Science
Archlinux PKGBUILDs for Data Science, Machine Learning, Deep Learning, NLP and Computer Vision
Stars: ✭ 92 (-7.07%)
Mutual labels:  package
grammarly
Grammarly API interface
Stars: ✭ 87 (-12.12%)
Mutual labels:  package
cookiecutter-pypackage
A cookiecutter template for Python package with heavy use of Github actions
Stars: ✭ 19 (-80.81%)
Mutual labels:  package
atom-package-sync
Synchronize your atom packages and settings easily
Stars: ✭ 22 (-77.78%)
Mutual labels:  package
version-check
An action that allows you to check whether your npm package version has been updated
Stars: ✭ 65 (-34.34%)
Mutual labels:  package
get-installed-path
Get locally or globally installation path of given package name.
Stars: ✭ 39 (-60.61%)
Mutual labels:  package
angular-loading-button
Loading button directive for AngularJS
Stars: ✭ 27 (-72.73%)
Mutual labels:  package
ContactEtc
Laraval package to instantly add a customisable contact form to your site.
Stars: ✭ 21 (-78.79%)
Mutual labels:  package
laravel-any
🏓 Laravel collection macro that determine if `any` item from the collection passes the given truth test.
Stars: ✭ 38 (-61.62%)
Mutual labels:  package

fusen

CRAN status R build status codecov test coverage

{fusen} inflates a Rmarkdown file to magically create a package.

If you know how to create a Rmarkdown file, then you know how to build a package.

Fill the flat Rmd template with everything in one place and {fusen} will inflate the identified parts in the correct package files and directories.

This {fusen} package is a real-world example of {fusen} use as it was itself created from the “dev_history” flat templates available in "dev/" folder in its GitHub repository.

Installation

You can install the released CRAN version:

install.packages("fusen")

Full documentation for the CRAN version is here: https://thinkr-open.github.io/fusen/

You can install the development version of {fusen} from GitHub:

# From r-universe.dev (No need for GITHUB_PAT)
install.packages("fusen", 
                 repos = c("thinkropen" = "https://thinkr-open.r-universe.dev"))

# With {remotes} using GitHub API
# install.packages("remotes")
remotes::install_github("ThinkR-open/fusen")

Full documentation for the development version is here: https://thinkr-open.github.io/fusen/dev/

You are one Rmd away from building a package!

{fusen} is all about correctly separating and naming chunks.

  • Create a new directory / new project with
    • RStudio template: File > New Project > New directory > Package using {fusen}
  • Choose the template
    • Choose the template teaching the first time to see how {fusen} works,
    • Choose the template full the second time to answer most of your questions
    • Or command line: create_fusen("path/to/new/project", template = "teaching")
  • Open the “dev/flat_teaching.Rmd” to start setting up the package
  • In this flat Rmd template, run the first chunks named description asking to describe your package and license it
    • They look like these lines of code:
fill_description(fields = list(Title = "My Awesome Package"))
usethis::use_mit_license("Sébastien Rochette")
  • Write your analysis and functionalities following the Rmd template
    • You probably develop them with a few examples and tests
    • For the first time, you can let the code as is, this is already the content for a working package
  • Run the following code to transform the flat Rmd as an inflated package
    • This will open the vignette created
fusen::inflate(
  flat_file = "dev/flat_teaching.Rmd",
  vignette_name = "Get started",
  check = TRUE
)

That’s it! You built a package! A documented and tested package!

Let’s test it now:

  • Install your package locally
remotes::install_local()
  • Restart your R session to clean environment
    • You can restart your RStudio session to let appear the “Build” tab panel
  • Test functions of your package
my.package::my_median(1:12)
  • Test the correct documentation of the package by building its dedicated website
# Build {pkgdown} to test it
usethis::use_pkgdown()
pkgdown::build_site()
# > See references and articles

Description of the Rmd template

As I said earlier, this is all about using the correct split and name for your chunks.

  • Follow the "dev/flat_template.Rmd" template to write your documentation and build your functions and test your examples.
    • Chunk named function gets the code of a function
    • Chunk named example gets the code for examples of using the function. This will be used for function @examples and will be kept for the vignette.
      • As chunk names should be unique in the future vignette, you can add function names like example-myfunction, example-myotherfunction, …
    • Chunk named tests gets the code for unit testing
    • Chunk named development gets the code for development purposes, usually only used once like {usethis} functions
  • Inflate the flat Rmd template to transform it as a package with functions, unit tests and the current Rmd transformed as a vignette. And check.

Note that the "flat*.Rmd" files created with templates full and teaching are indeed working examples that can directly be inflated.

You can also have a look at {squirrels.fusen} that has been built to present the method. Follow the commits: https://github.com/statnmap/squirrels.fusen/commits/main

How to maintain a {fusen}? Can I use {fusen} with old-way packages?

There is a dedicated vignette to answer this: https://thinkr-open.github.io/fusen/articles/Maintain-packages-with-fusen.html

  • Option 1: Modifications are only added to the “flat_template.Rmd” file, which then is inflated to update all packages files
  • Option 2: Modifications are realized in the package files directly, and the “flat_template.Rmd” file must be protected from any use.

Advice : Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place

Who is {fusen} for?

When you write a Rmarkdown file (or a vignette), you create a documentation for your analysis (or package). Inside, you write some functions, you test your functions with examples and you maybe write some unit tests to verify the outputs. This is even more true if you follow this guide : ‘Rmd first’: When development starts with documentation After that, you need to move your functions and scripts in the correct place. Let {fusen} do that for you!

{fusen} is first addressed to people who never wrote a package before but know how to write a Rmarkdown file. Understanding package infrastructure and correctly settling it can be frightening. This package may help them do the first step!

{fusen} is also addressed to more advanced developers who are fed up with switching between R files, tests files, vignettes. In particular, when changing arguments of a function, we need to change examples, unit tests in multiple places. Here, you can do it in one place. No risk to forget one. Think also about code review: everything related to one function is at the same place.

Why is this package named {fusen} ?

A fusen is an origami. It is a flat piece of paper that you fold in a specific way so that at the end, you can magically inflate it to let a nice box appear.

Similarly, the {fusen} package uses a flat Rmd template, that you fill in a specific way so that at the end, you can magically inflate() it to let a nice package appear.

Click here to fold your {fusen}…

Acknowledgments

Code of Conduct

Please note that the {fusen} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].