[R] RPart Simple Diagram issues

From: Jackie Gleason <jackiegleason_at_gmail.com>
Date: Wed, 06 Apr 2011 21:43:40 -0400

Hey everyone,

So I am looking for a way to create a decision tree for a modeling class and I am not all that familiar with R. I thought I might be able to use RPart, but I can't get it to work. I want a simple tree with a parent that says the amount and each child has a percentage of likelyhood and a payback so it would look something like this...


So I tried to do this by creating a table (again remember I am new)

>test <- matrix(c(000000.1,000000.9,1000,0,.1*1000, .9*0), ncol=2,
>colnames(test) <- c("Case A", "Case B")
>rownames(test) <- c("Chance", "Payoff", "Total")
> test <- as.table(test)

But when I run..
>fit <- rpart(Total ~ Chance * Payoff, method="class", data=test)

I see Error in eval(expr, envir, enclos) : object 'Chance' not found

I try...

fit <- rpart(Kyphosis ~ Age + Number + Start,

   method="class", data=kyphosis)

and it works fine.

Am I missing something here?


        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 07 Apr 2011 - 02:07:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Apr 2011 - 02:50:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive