From ee7a0be47d817d62c05d2f5e71dc3a6db9aa4a33 Mon Sep 17 00:00:00 2001 From: Ammar Azman <88831990+Ammar-Azman@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:15:42 +0800 Subject: [PATCH] Update app.R Convert play and outlook to factor to avoid model prediction error. --- shiny/003-play-golf/app.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shiny/003-play-golf/app.R b/shiny/003-play-golf/app.R index 3715ade..289b39d 100644 --- a/shiny/003-play-golf/app.R +++ b/shiny/003-play-golf/app.R @@ -14,6 +14,8 @@ library(randomForest) # Read data weather <- read.csv(text = getURL("https://raw.githubusercontent.com/dataprofessor/data/master/weather-weka.csv") ) +weather$play = factor(weather$play) +weather$outlook = factor(weather$outlook) # Build model model <- randomForest(play ~ ., data = weather, ntree = 500, mtry = 4, importance = TRUE)