## ------------------------------------------------------------
## classification
## ------------------------------------------------------------
## iris
#iris.obj <- rfsrc(Species ~., data = iris)
data(iris_rf, package="ggRandomForests")
## ------------------------------------------------------------
## regression
## ------------------------------------------------------------
## airquality
#airq.obj <- rfsrc(Ozone ~ ., data = airquality)
data(airq_rf, package="ggRandomForests")
gg_dta <- gg_variable(airq_rf)
plot(gg_dta, x_var="Wind")
plot(gg_dta, x_var="Temp")
plot(gg_dta, x_var="Solar.R")
## motor trend cars
#mtcars.obj <- rfsrc(mpg ~ ., data = mtcars)
data(mtcars_rf, package="ggRandomForests")
gg_dta <- gg_variable(mtcars_rf)
# mtcars$cyl is an ordinal variable
plot(gg_dta, x_var="cyl")
# Others are continuous
plot(gg_dta, x_var="disp")
plot(gg_dta, x_var="hp")
plot(gg_dta, x_var="wt")
## ------------------------------------------------------------
## survival examples
## ------------------------------------------------------------
## survival
# data(veteran, package = "randomForestSRC")
# veteran_rf <- rfsrc(Surv(time,status)~., veteran, nsplit = 10, ntree = 100)
data(veteran_rf, package="ggRandomForests")
# get the 30 day survival time.
gg_dta <- gg_variable(veteran_rf, time=30)
# Generate variable dependance plots for age and diagtime
plot(gg_dta, x_var = "age")
plot(gg_dta, x_var = "diagtime")
# If we want to compare survival at different time points, say 30, 90 day
# and 1 year
gg_dta <- gg_variable(veteran_rf, time=c(30, 90, 365))
# Generate variable dependance plots for age and diagtime
plot(gg_dta, x_var = "age")
plot(gg_dta, x_var = "diagtime")
Run the code above in your browser using DataLab