Tree-based ModelsLoading...
Basic statisticsScatter plot matrices Decision treePlotting the decision treeRandom forestVariable importance R session info
Note
This web application is developed with Shiny. List of Packages Used library(shiny)
library(shinyAce)
library(psych)
library(rpart)
library(partykit)
library(randomForest)
Code Source code for this application is based on "The handbook of Research in Foreign Language Learning and Teaching" (Takeuchi & Mizumoto, 2012). The code for this web application is available at GitHub.
If you want to run this code on your computer (in a local R session), run the code below:
Citation in Publications Mizumoto, A. (2015). Langtest (Version 1.0) [Web application]. Retrieved from http://langtest.jp Article Mizumoto, A., & Plonsky, L. (2015). R as a lingua franca: Advantages of using R for quantitative research in applied linguistics. Applied Linguistics, Advance online publication. doi:10.1093/applin/amv025 Recommended To learn more about R, I suggest this excellent and free e-book (pdf), A Guide to Doing Statistics in Second Language Research Using R, written by Dr. Jenifer Larson-Hall. Also, if you are a cool Mac user and want to use R with GUI, MacR is defenitely the way to go! Author
Atsushi MIZUMOTO,
Ph.D.
|
library(shiny)
library(shinyAce)
library(psych)
library(rpart)
library(partykit)
library(randomForest)
shinyServer(function(input, output) {
bs <- reactive({
x <- read.csv(text=input$text, sep="\t")
describe(x)[2:13]
})
output$textarea.out <- renderPrint({
bs()
})
makecorPlot <- function(){
x <- read.csv(text=input$text, sep="\t")
pairs.panels(x)
}
output$corPlot <- renderPlot({
print(makecorPlot())
})
output$varselect1 <- renderUI({
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
cols <- names(dat)
selectInput("vars1", "Select one criterion (outcome) variable:", choices=cols, selected=NULL, multiple=FALSE)
})
output$varselect2 <- renderUI({
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
cols <- names(dat)
selectInput("vars2", "Click the box below and select the explanatory variables:", choices=cols, multiple=T)
})
decisiontree <- reactive({
if (input$explvars == "all") {
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
#outcome <- dat[,input$vars1]
#dat[,input$vars1] <- NULL
#res <- rpart(outcome ~., data=dat)
res <- rpart(as.formula(paste(input$vars1, "~.")),data=dat)
print(res)
} else { # select
if (is.null(input$vars2) == TRUE){
res <- c("You need to select the explanatory variables.")
print(res)
} else {
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
res <- rpart(as.formula(paste(input$vars1," ~ ",paste(input$vars2,collapse="+"))),data=dat)
print(res)
}
}
list(res = res)
})
output$dtree <- renderPrint({
decisiontree()
})
dtreePlot <- function(){
if (input$explvars == "all") {
res <- decisiontree()$res
plot(as.party(res))
} else {
if (is.null(input$vars2) == TRUE){
NULL
} else {
res <- decisiontree()$res
plot(as.party(res))
}
}
}
output$dtreePlot <- renderPlot({
print(dtreePlot())
})
randforest <- reactive({
if (input$explvars == "all") {
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
forest <- randomForest(as.formula(paste(input$vars1,"~.")),data=dat)
impt <- forest$importance
} else { # select
if (is.null(input$vars2) == TRUE){
forest <- c("You need to select the explanatory variables.")
impt <- c("You need to select the explanatory variables.")
} else {
dat <- read.csv(text=input$text, sep="\t", na.strings=c("","NA","."))
forest <- randomForest(as.formula(paste(input$vars1," ~ ",paste(input$vars2,collapse="+"))),data=dat)
impt <- forest$importance
}
}
list(result = forest, importance = impt)
})
output$randforest <- renderPrint({
randforest()
})
errorPlot <- function(){
if (input$explvars == "all") {
forest <- randforest()$result
plot(forest, main="Error rate")
} else {
if (is.null(input$vars2) == TRUE){
NULL
} else {
forest <- randforest()$result
plot(forest, main="Error rate")
}
}
}
output$errorPlot <- renderPlot({
print(errorPlot())
})
varimPlot <- function(){
if (input$explvars == "all") {
forest <- randforest()$result
varImpPlot(forest, main="")
} else {
if (is.null(input$vars2) == TRUE){
NULL
} else {
forest <- randforest()$result
varImpPlot(forest, main="")
}
}
}
output$varimPlot <- renderPlot({
print(varimPlot())
})
info <- reactive({
info1 <- paste("This analysis was conducted with ", strsplit(R.version$version.string, " \\(")[[1]][1], ".", sep = "")
info2 <- paste("It was executed on ", date(), ".", sep = "")
cat(sprintf(info1), "\n")
cat(sprintf(info2), "\n")
})
output$info.out <- renderPrint({
info()
})
})
library(shiny)
library(shinyAce)
shinyUI(bootstrapPage(
headerPanel("Tree-based Models"),
########## Adding loading message #########
tags$head(tags$style(type="text/css", "
#loadmessage {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
padding: 10px 0px 10px 0px;
text-align: center;
font-weight: bold;
font-size: 100%;
color: #000000;
background-color: #CCFF66;
z-index: 105;
}
")),
conditionalPanel(condition="$('html').hasClass('shiny-busy')",
tags$div("Loading...",id="loadmessage")),
#-----------------------------------------#
mainPanel(
tabsetPanel(
tabPanel("Main",
p(HTML("<b><div style='background-color:#FADDF2;border:1px solid black;'>The editor below only accepts tab-separated values copied and pasted from Excel/Numbers. </div></b>")),
aceEditor("text", value="SE\tSelf.manage\tInput\tImagery\tWrite\tOral\tAssociation\tGoal\tVolition\tSatisfaction\n1.75\t1.86\t4\t4.8\t6\t4.33\t4\t2\t3\t4.5\n1\t1.14\t3\t3.2\t4\t3\t2.67\t2.75\t1.8\t2.5\n3\t3.14\t3.75\t4\t4.67\t4.33\t4\t4.25\t3.8\t4\n2.75\t3.86\t4.75\t4.6\t4.67\t6\t4.67\t3.25\t3\t4.25\n2\t2.71\t3.25\t3.6\t3.67\t2.67\t5.33\t4.5\t3\t4.75\n1\t1\t5.25\t2\t2.67\t4.33\t1\t1\t1\t1\n3.5\t3.29\t4.5\t3.2\t2.67\t3.33\t3.67\t3.75\t4\t4\n2.5\t1.71\t3\t1.4\t2.33\t2.33\t2.67\t2\t2\t2.25\n1.5\t2.71\t2.5\t2.8\t3.67\t1.67\t1.33\t2.5\t2.8\t2.5\n4\t3.43\t5.75\t3.6\t3.67\t4.33\t4\t3\t4.2\t3\n3.75\t2.43\t4\t4.6\t6\t4.33\t4\t3.25\t3\t4.5\n3\t3.86\t4.5\t5.4\t6\t4.67\t4.33\t5\t3.6\t5\n1.25\t3.14\t2.5\t4\t5\t3.33\t2\t2.75\t2\t2.75\n3.25\t3.86\t2.75\t3.8\t5\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4\t4.6\t5.67\t4\t3\t3.75\t3.4\t3.5\n1.75\t4\t4\t3.8\t6\t2.33\t4.67\t2.25\t3.4\t3\n2.25\t3.43\t1.5\t2\t3.67\t1.67\t2\t2.5\t2\t2\n2.25\t2.71\t4.75\t3.2\t3.67\t3.67\t2.33\t3\t1.8\t3\n3.25\t1.29\t2.25\t3.6\t5.33\t3\t4\t4.25\t4\t3.25\n3.25\t4.43\t5.75\t3.6\t1\t6\t4.33\t2.25\t1\t2\n1.25\t2.57\t4\t3\t2.67\t4.33\t2.67\t3.75\t1.6\t2.5\n4.75\t2.86\t3.25\t4\t6\t6\t5\t3.25\t3.2\t4.5\n1.25\t1\t1\t3.4\t2.67\t1.33\t1.67\t2.25\t1.4\t1.25\n3.75\t3\t4\t4\t5\t3.67\t3.33\t3\t3.4\t3.5\n2\t4.57\t5.5\t5\t4\t5.33\t4.33\t4\t3.8\t4\n3\t2.71\t4.25\t4.8\t5.33\t3\t5.33\t2.75\t4.2\t3.5\n3.75\t3.29\t3.75\t3.2\t5.67\t4\t5.67\t5.5\t5.6\t4.75\n3.5\t4\t4.75\t5.4\t5\t4.33\t5\t4.75\t4.2\t5\n2\t3.29\t2\t4.8\t4.33\t3\t5\t1.75\t3.2\t3.75\n3.75\t2.57\t3.5\t3.6\t2.67\t4.67\t3.67\t3.5\t4.4\t4\n1\t2.14\t1.25\t3.2\t6\t2.33\t2\t2.25\t2.2\t1\n2.5\t2.14\t2.5\t4\t2\t4\t3\t2.25\t2.2\t2.5\n4.25\t4.29\t4.25\t4.8\t5.67\t4.67\t4.67\t5.25\t5.4\t5.25\n3.75\t3.43\t4.5\t3.8\t2.33\t3\t4\t3.5\t4\t4.5\n1.75\t2.86\t3.5\t4.6\t6\t6\t5\t5\t4.6\t6\n4.25\t2.29\t3.5\t2.8\t2\t2.67\t4.33\t4\t2.8\t4.25\n1.25\t4.29\t2.5\t4\t2.67\t4\t3.67\t4\t3.8\t3.75\n2\t1.71\t4\t3.6\t4.67\t2.67\t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\t2.2\t2.25\n4.25\t1.57\t3.5\t3.2\t3.33\t1.67\t1\t1\t2.4\t1\n2\t3.71\t2\t3.4\t2\t2.33\t4.67\t3.5\t3\t3.5\n3.25\t3.71\t3.25\t3.6\t4\t4.67\t4\t3.25\t4\t4\n3.75\t3.43\t5.25\t5.4\t4\t4.33\t5\t3.75\t4.2\t4.75\n1.25\t1.29\t1\t2.4\t6\t2\t1\t1\t1.6\t2.5\n2.75\t2.86\t2.5\t3\t4.67\t2.33\t1.33\t3\t2.4\t3\n2.5\t2.14\t5.5\t3.4\t2\t1.67\t3.33\t1.5\t1.4\t1.5\n3.25\t1.43\t1.75\t4\t3.67\t4\t2.67\t4\t3\t3.5\n1\t1.14\t2.25\t2.2\t3.33\t1.33\t1\t2\t1.2\t2.25\n2\t2.43\t2.5\t4.2\t4.67\t3\t3\t3.25\t2.2\t3.5\n2.5\t3.29\t4.25\t3.6\t2.67\t4.67\t4\t2.75\t3\t3.5\n3\t4.29\t4.25\t4.8\t5\t4.67\t4\t5\t3\t4.25\n2.75\t3.43\t3.5\t4.8\t4.67\t3\t4.33\t5\t2.6\t3\n3.5\t1.71\t3.25\t3\t2.67\t1\t2.67\t2.75\t2\t2.75\n5\t4.14\t4.5\t3\t4.67\t3\t1.33\t2.75\t3.8\t4.5\n2\t3.71\t3.75\t3.6\t3.33\t3.33\t3\t1.75\t2.2\t3\n1.5\t2\t2\t3.2\t2.67\t5.33\t3.33\t5.5\t3.2\t3.5\n3.75\t3.29\t4.5\t5.6\t3.33\t4.33\t5.67\t5.75\t5.6\t5.5\n1.25\t1.43\t2\t1.2\t2.33\t2\t1\t1\t1\t1\n3.25\t3.43\t2.75\t3.2\t3.67\t3\t4.33\t3.75\t3.4\t3.75\n3.75\t3.14\t6\t3.4\t6\t4.33\t2\t3.5\t4\t4\n4\t3.14\t2.75\t4.4\t3.33\t2.67\t5.33\t4.75\t2.8\t3.75\n1.75\t1.29\t2.25\t3\t3.67\t2.67\t3.33\t2\t2.2\t2\n5\t3.14\t5.75\t5\t3.67\t6\t5.33\t6\t3.6\t4\n3.5\t3.86\t6\t4\t2.67\t6\t1\t2.25\t1\t4.75\n3.5\t3.57\t4.5\t3.8\t4.33\t4\t3.67\t3\t4\t4\n3.25\t3.86\t4.5\t4.6\t6\t4.67\t3.67\t4.5\t4\t4\n3.25\t1.71\t4.75\t4\t1.67\t1.67\t4.67\t3.5\t2.4\t3.75\n1.75\t2.14\t2.25\t4.4\t3.33\t3.67\t2\t2.75\t2.4\t3.5\n5.25\t3.43\t5.5\t3.6\t5.33\t4.67\t4.33\t2\t2.8\t4.25\n2.25\t2.57\t2\t2.2\t3\t2\t1.67\t2\t2\t2.25\n2.5\t1\t1\t4\t4.33\t2.33\t3\t1.5\t1\t1.5\n4\t4.43\t5\t4\t4\t4.67\t4.67\t4.25\t4.8\t4.75\n3.75\t3\t3.75\t3\t6\t5\t3.67\t2.5\t4.6\t5\n2.5\t3\t2\t3.4\t3\t2\t2\t1.5\t2\t2\n4.25\t2.71\t5.25\t4\t2.33\t4\t4.33\t3\t3.2\t4.25\n2.25\t2.29\t3.75\t3.2\t2.67\t2.67\t3\t1\t2.6\t3.75\n3\t3.43\t3.75\t3.4\t5\t4.33\t4\t3.75\t3\t3.5\n3.5\t4.14\t5.75\t5.4\t5.67\t3.67\t5.33\t3.75\t3.8\t4.25\n2.5\t1.43\t1\t3.8\t2.33\t1\t4\t2.25\t1\t1.5\n2\t2.86\t3.75\t3.8\t5.33\t4.33\t3\t3.5\t3.8\t4\n3.75\t4.29\t4.25\t4\t5\t4.67\t3\t4\t4\t4\n3.75\t4.43\t5.75\t3.6\t4.33\t4.67\t3\t4.5\t3.6\t3.25\n2\t3\t3.25\t3.4\t2.67\t2.67\t2.33\t2.75\t2\t2.75\n2.5\t4.14\t3.25\t4.2\t3.33\t4\t5\t3\t3\t3\n4\t3.14\t5.5\t4.6\t6\t5.67\t4.33\t4.25\t5\t4.75\n2.75\t3.43\t5\t4.8\t4\t3.67\t4.33\t4\t4.2\t4.25\n3.5\t2.43\t5.75\t3.8\t3.67\t5.33\t2.67\t2.25\t3.6\t3.5\n2.75\t2.86\t4.5\t3.6\t4.67\t4\t3.33\t4.75\t4.8\t3.75\n3\t3.14\t3.5\t3.4\t4.67\t5\t4\t3.25\t3\t3\n3.25\t4\t5.25\t2.4\t4.33\t6\t4\t4\t3.8\t3.75\n1.75\t2.14\t3.25\t4\t4.67\t3.67\t2\t2.75\t2\t2.25\n4.75\t4.71\t6\t5.4\t4.33\t4.67\t5\t4.5\t4.2\t5\n4.25\t3.86\t5\t4.8\t4\t6\t5.67\t4\t5.2\t5\n2\t2.29\t3.75\t3\t5\t3.33\t2\t2.75\t3.8\t3\n4.5\t3.71\t4.5\t4.2\t4.67\t4.67\t4.67\t4.5\t4.6\t4.75\n2\t2.43\t4.5\t4.2\t3.67\t4\t3\t1.75\t2\t2.75\n2\t2\t2.5\t2.4\t4.67\t1\t2.33\t3\t2.4\t2\n2.25\t3.57\t4.75\t4.2\t4.33\t4.33\t6\t3.75\t4.8\t4.5\n2\t3.71\t2.75\t4.6\t4.67\t5\t3\t1.25\t3.6\t2.25\n3\t3.14\t3.75\t3.8\t3.67\t5\t3.67\t4.25\t3.2\t3.25\n1.25\t1.43\t3\t3.2\t3.67\t2\t4\t4.75\t3.4\t1.5\n2.75\t3.14\t2.5\t2\t2.33\t2.67\t1.67\t3.75\t2.8\t2.5\n2.25\t2.86\t3.75\t4\t4.33\t3.67\t3.33\t3.75\t2.8\t3.25\n3.25\t4\t6\t4\t1.33\t4.33\t5\t4\t4\t4.25\n1.75\t3.29\t3.5\t3.2\t3\t3\t3.33\t2.25\t1.2\t2.5\n2.75\t3\t4.5\t2.8\t3\t4\t2.67\t3\t2.4\t2.75\n3.25\t3.57\t3.25\t2.4\t3.33\t1.67\t2\t4.25\t2.6\t4.75\n3.25\t3.29\t2.75\t2.4\t2\t3.67\t1.33\t4.25\t4.6\t4.75\n4\t2.57\t4.5\t2.6\t3.33\t3\t2.67\t4.75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.6\t4.67\t4.33\t4\t3\t3.6\t4.25\n4.25\t3.29\t4.25\t4.8\t3.67\t4\t4.33\t3.5\t2.8\t4.5\n2.5\t3\t4.5\t2.8\t4\t3\t4\t2.5\t2\t3.25\n2.25\t2.14\t3.25\t3.8\t4.33\t2.67\t2.33\t4.25\t3.4\t3.75\n2\t2.71\t1\t3.4\t1.67\t6\t4\t6\t5\t5.25\n5\t1.71\t5.25\t3\t6\t2.33\t1.67\t6\t6\t6\n2.5\t1.29\t1\t3\t2\t1\t2\t1.5\t2\t1.75\n2.5\t2.29\t1.75\t2.6\t3.67\t5\t3.33\t3\t2.6\t3.5\n2.5\t3.43\t4\t4.2\t4.33\t4\t3.67\t4.75\t4.2\t4\n3\t1.86\t4.25\t4\t2.67\t4.67\t2\t1.5\t5.2\t3.5\n1.5\t1.57\t4.75\t4\t2.33\t4.33\t3.33\t2.5\t2\t1\n3.75\t2\t5.75\t2.8\t4.33\t5\t5.33\t5\t5.4\t5.5\n1.25\t1.57\t2.75\t2.2\t4.33\t2\t1.67\t1.25\t2.2\t2\n2.5\t5.29\t6\t6\t6\t4.33\t6\t6\t2\t4.75\n3\t1.86\t4.5\t5.2\t6\t1.67\t4\t1\t2.2\t4.75\n3.75\t2.86\t6\t4.6\t4.33\t5.33\t4.67\t3.75\t3.8\t4.5\n3.75\t4.71\t3.5\t4.6\t5\t4\t3.67\t3.75\t4.8\t4\n4\t3.57\t4\t5\t3.67\t4.33\t2.67\t3\t4\t4.5\n5.5\t3.71\t4.75\t5\t4.33\t5\t5\t2\t5.4\t4.25\n1\t1.71\t1.5\t1.8\t3\t1.67\t1.67\t1\t1.2\t1.25\n2.75\t2.71\t4.75\t3.2\t3.33\t4\t2.67\t3\t4.6\t3.75\n3.25\t4.29\t4.25\t4.4\t5\t5\t4\t4.5\t5\t5",
mode="r", theme="cobalt"),
br(),
h3("Basic statistics"),
verbatimTextOutput("textarea.out"),
br(),
strong("Scatter plot matrices"),
br(),
plotOutput("corPlot", width="120%"),
br(),
h3("Decision tree"),
uiOutput("varselect1"),
radioButtons("explvars", "Choose explanatory variables:",
list("All" = "all", "Select" = "select"), selected = "all"),
# Display this only if "expl.vars" is "select"
conditionalPanel(condition = "input.explvars == 'select'",
uiOutput("varselect2")
),
verbatimTextOutput("dtree"),
br(),
h3("Plotting the decision tree"),
br(),
plotOutput("dtreePlot", width="120%"),
br(),
h3("Random forest"),
verbatimTextOutput("randforest"),
plotOutput("errorPlot", width="80%"),
br(),
strong("Variable importance"),
plotOutput("varimPlot"),
br(),
br(),
br(),
strong('R session info'),
verbatimTextOutput("info.out")
),
tabPanel("About",
strong('Note'),
p('This web application is developed with',
a("Shiny.", href="http://www.rstudio.com/shiny/", target="_blank"),
''),
br(),
strong('List of Packages Used'), br(),
code('library(shiny)'),br(),
code('library(shinyAce)'),br(),
code('library(psych)'),br(),
code('library(rpart)'),br(),
code('library(partykit)'),br(),
code('library(randomForest)'),br(),
br(),
strong('Code'),
p('Source code for this application is based on',
a('"The handbook of Research in Foreign Language Learning and Teaching" (Takeuchi & Mizumoto, 2012).', href='http://mizumot.com/handbook/', target="_blank")),
p('The code for this web application is available at',
a('GitHub.', href='https://github.com/mizumot/trees', target="_blank")),
p('If you want to run this code on your computer (in a local R session), run the code below:',
br(),
code('library(shiny)'),br(),
code('runGitHub("trees","mizumot")')
),
br(),
strong('Citation in Publications'),
p('Mizumoto, A. (2015). Langtest (Version 1.0) [Web application]. Retrieved from http://langtest.jp'),
br(),
strong('Article'),
p('Mizumoto, A., & Plonsky, L. (2015).', a("R as a lingua franca: Advantages of using R for quantitative research in applied linguistics.", href='http://applij.oxfordjournals.org/content/early/2015/06/24/applin.amv025.abstract', target="_blank"), em('Applied Linguistics,'), 'Advance online publication. doi:10.1093/applin/amv025'),
br(),
strong('Recommended'),
p('To learn more about R, I suggest this excellent and free e-book (pdf),',
a("A Guide to Doing Statistics in Second Language Research Using R,", href="http://cw.routledge.com/textbooks/9780805861853/guide-to-R.asp", target="_blank"),
'written by Dr. Jenifer Larson-Hall.'),
p('Also, if you are a cool Mac user and want to use R with GUI,',
a("MacR", href="https://sites.google.com/site/casualmacr/", target="_blank"),
'is defenitely the way to go!'),
br(),
strong('Author'),
p(a("Atsushi MIZUMOTO,", href="http://mizumot.com", target="_blank"),' Ph.D.',br(),
'Professor of Applied Linguistics',br(),
'Faculty of Foreign Language Studies /',br(),
'Graduate School of Foreign Language Education and Research,',br(),
'Kansai University, Osaka, Japan'),
br(),
a(img(src="http://i.creativecommons.org/p/mark/1.0/80x15.png"), target="_blank", href="http://creativecommons.org/publicdomain/mark/1.0/"),
p(br())
)
))
))