updated the code to handle error

This commit is contained in:
Bharath Sankaranarayan
2019-02-28 11:07:18 -08:00
committed by GitHub
parent 6fd2d7953b
commit 3395997b70
@@ -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)