#Mastano's Project
#Decision Model
# Load the party package. It will automatically load other
# dependent packages.
setwd("c:/users/Paul/Documents/Rwork")
getwd()
## [1] "c:/users/Paul/Documents/Rwork"
library(readr)
vuldata<- read.csv(file="vuldata.csv")
library(rpart)
## Warning: package 'rpart' was built under R version 3.5.3
# Create the tree for Mastano's project
tree <- rpart(WaterSource~wateradequacy+gender+education + occupation,data = vuldata,cp=0.02)
tree
## n= 60
##
## node), split, n, loss, yval, (yprob)
## * denotes terminal node
##
## 1) root 60 28 Not Vulnerable (0.5333333 0.4666667)
## 2) wateradequacy>=1.5 19 4 Not Vulnerable (0.7894737 0.2105263) *
## 3) wateradequacy< 1.5 41 17 Vulnerable (0.4146341 0.5853659) *
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 3.5.2
library(rattle)
## Warning: package 'rattle' was built under R version 3.5.3
## Rattle: A free graphical interface for data science with R.
## Version 5.3.0 Copyright (c) 2006-2018 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 3.5.3
rpart.plot(tree)
