Testing in R- Introduction

Resources for testing in R is not readily available. In this series- (Testing in R). I would be sharing my learnings in a comprehensible format.

The problem with data analysis is that a small mistake in your model can give you a big change in your results.

May be the columns that you are working on cannot have negative values, or should have a range of value or specific criteria which tests the validity of your data. Testing helps to automate the checks, both in your logic and data.

Another aspect of incorporating testing in your work is when you are developing an R package that is to be publically available (perhaps on CRAN). Users will certainly be using your code in ways that you didn’t imagine, and on datasets in different formats.

Testing would be needed in the following two scenarios-

  • Unit Testing (Development Time Testing)- When you want to avoid the errors during the development time- this is for the developer to put checks on the logic, that she has written.
  • Runtime Testing helps to prevent user errors. This is to check bad user inputs. e.g. – only numbers are accepted for arithmetic operations.

In Summary, the point of development time testing is to check developer’s error, while run-time testing is mainly to put a check or inform users on incorrect inputs.

I will be sharing more in detail in the next posts.

Leave a Reply

Your email address will not be published. Required fields are marked *