NotebookToSite R Package

in #utopian-io6 years ago (edited)

Introduction

Here is an R package I put together to help with making my project work more accessible and standardized. The main function, create_site(), will allow the user to create an Rmarkdown file to use as a notebook that will be rendered into an html file as well. This will be placed in the docs directory of your project. This in turn makes it able to used by Github Pages for the repository. To enable this, under your repository go to the Settings tab, scroll down to the Github Pages section and under the source option change the drop down menu from 'None' to 'master branch/docs folder'. Just like that you have a basis for a website to share your project analysis!

There are several directories created including docs, src, results and references. I have found these are broad enough to encompasses most of what is necessary for a project. You could easily argue for others or consolidation of these directories. An Rmarkdown file is created for a Notebook and placed in the src directory. It will also created a sub directory of src/chunks. Each Notebook chunk will be separated out and converted into its own .R file and placed in the chunks directory while maintaining the full Notebook.Rmd file as well. Each .R file will be named after the chunk it came from, making it important that you name your chunks in your notebook to find them later on. This helped keep me honest in documenting my code knowing this will be important later on. Also each chunk has #!/usr/bin/env Rscript in order to be run as a standalone Rscript file. Finally an index.html file and a Notebook.html file are created as well which can be edited later.

Every time updates are made to the notebook, there is another function to update_site() that will take the latest Notebook.Rmd file and save each chunk again to its own .R file and knit the Notebook.html file again to reflect the latest updates. There is also an index.Rmd file that was made and placed in the src directory that can be updated. This would be the main part of your new website and can be edited as desired.

Future Work

This is the first iteration of this package and I wanted to get it out there. I would love to hear feedback and suggestions for the package. I had pieces of this in R scripts that I would use to do some of these tasks. i decided it would be easier just to create a package and make some easy to use functions. One draw back may be it assumes too much and people might not like that. It is something that I have worked out for my workflow. I might try to add more flexibility to it. I could see adding options and modules to pick and choose things for your specific project. I didn't want it to be too complicated but at the same time want to be broad enough to be useful. I would gladly take pull requests or suggestions. Hope this helps some people!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @kirk-gosik I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • This is your first accepted contribution here in Utopian. Welcome!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

I have to point out a few things though.

  • You uploaded the whole project to GitHub in one single commit. This makes it hard to evaluate the history of the project and the actual work that has been done. For future projects you should use Git/GitHub right from the beginning.
  • There's no LICENSE file. Without it your project is, legally speaking, not open source. You should definitely add one.
  • The DESCRIPTION is still mostly the template from RStudio.

You can contact us on Discord.
[utopian-moderator]

Thank you for the feedback. I will be sure to update all of this. I will also make sure all of this is done before submitting anything in the future. Thanks again