testthat is a testing framework developed by Hadley Wickham, which makes unit testing easy for developers. Test scripts developed can be re-run after debugging or making changes to the functions without the hassle of developing the code for testing again. testthat has a heirarchical structure made up of expectations, tests and contexts. Visit this link […]

## Unit testing in R using testthat library – Solutions

Below are the solutions to these exercises on unit testing in R. #################### # # # Exercise 1 # # # #################### install.packages("testthat") library(testthat) # loading the package #################### # # # Exercise 2 # # # #################### #Passes expect_that(5*2, equals(10)) #################### # # # Exercise 3 # # # #################### #Passes expect_that(5*2, equals(10+ 1e-7)) […]

## Plotly : Advanced plots and features

Plotly is a d3 based graphing library used to produce interactive and high quality graphs in R. In the following exercises, we will look at some advanced plots and features avaialable in the package. Please note that the list here is not exhaustive. We will use datasets available in base R packages. You are expected […]

## Plotly : Advanced plots and features – Solutions

Below are the solutions to these exercises on Plotly advanced features. #################### # # # Exercise 1 # # # #################### library(plotly) # loading the package p1 <- plot_ly(x = iris[,1], type = “histogram”, name = names(iris)[1]) p2 <- plot_ly(x = iris[,2], type = “histogram”, name = names(iris)[2]) p3 <- plot_ly(x = iris[,3], type = […]

## Getting started with Plotly: basic Plots

Plotly is a d3 based graphing library used to produce interactive and high quality graphs in R. In the following exercises, we will look at the basic plots’ syntax and some basic features in the plotly functions. We will use datasets available in base R packages. Refer to the documentation of the plotly packages when […]

## Getting started with Plotly: basic Plots – Solutions

Below are the solutions to these exercises on plotly basic plots library(plotly) ############### # # # Exercise 1 # # # ############### plot_ly(x = iris[,1]) #type = “histogram” is the argument to be included to specify the chart type ############### # # # Exercise 2 # # # ############### #nbinsx is the argument to specify […]