Rev 6302 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R version 2.15.0 (2012-03-30)Copyright (C) 2012 The R Foundation for Statistical ComputingISBN 3-900051-07-0Platform: x86_64-unknown-linux-gnu (64-bit)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type 'license()' or 'licence()' for distribution details.R is a collaborative project with many contributors.Type 'contributors()' for more information and'citation()' on how to cite R or R packages in publications.Type 'demo()' for some demos, 'help()' for on-line help, or'help.start()' for an HTML browser interface to help.Type 'q()' to quit R.> library(rpart)> require(survival)Loading required package: survivalLoading required package: splines> aeq <- function(x,y, ...) all.equal(as.vector(x), as.vector(y), ...)>> #> # Check out using costs> #> fit1 <- rpart(Surv(time, status) ~ age + sex + ph.ecog + ph.karno + pat.karno+ + meal.cal + wt.loss, data=lung,+ maxdepth=1, maxcompete=6, xval=0)>> fit2 <- rpart(Surv(time, status) ~ age + sex + ph.ecog + ph.karno + pat.karno+ + meal.cal + wt.loss, data=lung,+ maxdepth=1, maxcompete=6, xval=0, cost=(1+ 1:7/10))>> temp1 <- fit1$splits[1:7,]> temp2 <- fit2$splits[1:7,]> temp3 <- c('age', 'sex', 'ph.ecog', 'ph.karno', 'pat.karno', 'meal.cal',+ 'wt.loss')> indx1 <- match(temp3, dimnames(temp1)[[1]])> indx2 <- match(temp3, dimnames(temp2)[[1]])> aeq(temp1[indx1,1], temp2[indx2,1]) #same n's ?[1] TRUE> aeq(temp1[indx1,3], temp2[indx2,3]*(1+ 1:7/10)) #scaled importance[1] TRUE>>>> proc.time()user system elapsed0.288 0.067 0.407