From 3395997b7002d83fe45275603f00b6fad792bbac Mon Sep 17 00:00:00 2001 From: Bharath Sankaranarayan Date: Thu, 28 Feb 2019 11:07:18 -0800 Subject: [PATCH] updated the code to handle error --- .../app-deploy/RollDice/roll-dice.R | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/samples/features/sql-big-data-cluster/app-deploy/RollDice/roll-dice.R b/samples/features/sql-big-data-cluster/app-deploy/RollDice/roll-dice.R index f0e2002c..7d87ec8a 100644 --- a/samples/features/sql-big-data-cluster/app-deploy/RollDice/roll-dice.R +++ b/samples/features/sql-big-data-cluster/app-deploy/RollDice/roll-dice.R @@ -9,15 +9,20 @@ #install.packages("TeachingDemos") rollEm <- function(numDice = 2) + { -list.of.packages <- c("TeachingDemos") -new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] -if(length(new.packages)) install.packages(new.packages) + if (numDice < 11) + { + list.of.packages <- c("TeachingDemos") + new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] + if(length(new.packages)) install.packages(new.packages) library(TeachingDemos) - - r<-dice(ndice = numDice) - return(as.data.frame(r)) + r<-dice(ndice = numDice) + return(as.data.frame(r)) + } + else {"Oops we have not quite figued this out... number of dice need to be less than or equal to 10!"} } + result<-rollEm(x)