Book Image

Mastering RStudio: Develop, Communicate, and Collaborate with R

4 (1)
Book Image

Mastering RStudio: Develop, Communicate, and Collaborate with R

4 (1)

Overview of this book

RStudio helps you to manage small to large projects by giving you a multi-functional integrated development environment, combined with the power and flexibility of the R programming language, which is becoming the bridge language of data science for developers and analyst worldwide. Mastering the use of RStudio will help you to solve real-world data problems. This book begins by guiding you through the installation of RStudio and explaining the user interface step by step. From there, the next logical step is to use this knowledge to improve your data analysis workflow. We will do this by building up our toolbox to create interactive reports and graphs or even web applications with Shiny. To collaborate with others, we will explore how to use Git and GitHub and how to build your own packages to ensure top quality results. Finally, we put it all together in an interactive dashboard written with R.
Table of Contents (17 chapters)
Mastering RStudio – Develop, Communicate, and Collaborate with R
About the Authors
About the Reviewer

Testing a package

When we build a package, it is very important to test it. Packages can get very complex structures and this creates a high potential for bugs. The most basic way to test your package is to build and load it again and again and test all its functions simply by using them. But this only works up to a certain package size. If our package gets too big, we cannot test every single function after every change we made to the package.

The better way to test our packages when they reach a certain size is the testthat package, created by Hadley Wickham, who also created the devtools package. This package is available on CRAN, so we can simply install it with the install.packages() function.

Using testthat in a package

Before we can use testthat in your project, we have to call the use_testthat() function from the devtools package once. This function will set up all folders and dependencies and create the tests folder.

This folder includes a testthat.R file and the testthat folder, which...