r - How do I transform an rpart object (result of rpart() function) into a data frame? -


i have data set (let's call "x") looks this...

x <- structure(list(top_bracket_style = c("29l", "23r", "29l", "29r",  "29r", "29l", "29r", "29r", "29r", "29r", "29r", "29r", "29r",  "29l", "90"), column_finish = c("pt", "aw", "pt", "pt", "ml",  "pt", "ml", "pt", "ml", "pt", "pt", "ml", "pt", "pt", "pt"),      foot_finish = c("pt", "aw", "pt", "pt", "ml", "pt", "ml",      "pt", "ml", "pt", "pt", "ml", "pt", "pt", "pt"), glide_style = c("s",      "s", "s", "s", "s", "s", "s", "s", "l", "s", "s", "s", "s",      "s", "s"), cycle_time = c(73l, 148l, 137l, 132l, 139l, 129l,      198l, 110l, 116l, 138l, 130l, 138l, 97l, 132l, 170l)), .names = c("top_bracket_style",  "column_finish", "foot_finish", "glide_style", "cycle_time"), row.names = c(na,  15l), class = "data.frame") 

the data describe furniture product made in plant on machine. top bracket style, column finish, foot finish, , glide style 4 characteristics describe distinct configuration of options product build. cycle time amount of time takes build product, start finish.

i use

fit <- rpart(cycle_time ~ top_bracket_style + column_finish +     foot_finish + glide_style, method = "anova", data = x) 

to partition data can identify groups/clusters have similar mean cycle times. when "print(fit)" following results...

1) root 16933 21747274.710800 134.1567944251   2) top_bracket_style=23l,23r,29l,29r 15591 18965219.863130 132.0181514977 *   3) top_bracket_style=120,35l,35r,90 1342  1882283.988077 159.0029806259 * 

what want accomplish seems simple, cannot find way accomplish it, extending searching on cran , stack overflow. transform rpart results data frame looks this...

enter image description here

this data frame serve lookup table entering cycle time our production database responsible scheduling our machines in our plants. not @ point, yet, want use decision tree predict cycle times (with predict() function). now, more controlled that. content collect data off machines making these products, , improve our cycle time calculations go.

any appreciated.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -