问题
This is the code I entered into RStudio to create a decision tree, and park
is a data frame I have in my environment
people <- park %>%
select(Subj, Parkinson, fhi, jitter, rap, shimmer, apq, nhr) %>%
na.omit()
glimpse(people)
tally(~ Parkinson, data = people, format = "percent") # simple table
################
set.seed(1688)
#############
# Tree with rpart
whoHasPark <- rpart(Parkinson ~ Subj, fhi, jitter,
data = people, control = rpart.control(cp = 0.005, minbucket = 30))
whoHasPark
plot(as.party(whoHasPark))
This is the error I got back:
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' is a list, but does not have components 'x' and 'y'
Where did I go wrong?
回答1:
Not sure, but that could be because you are giving Parkinson ~ Subj, fhi, jitter
(separating them by comma throws an error) in your rpart call. Trying with '+' might help Parkinson ~ Subj + fhi + jitter
.
来源:https://stackoverflow.com/questions/47190465/fit-a-decision-tree-classifier-to-the-data-error-in-code