Skip to content

Commit

Permalink
fixed issue with options for CFA
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehamilton committed Mar 5, 2016
1 parent 905c29f commit 720efe5
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ library(psych)
library(lavaan)
library(semPlot)
shinyServer(function(input, output) {

bscfa <- reactive({
x <- read.csv(text=input$textcfa, sep="\t")
describe(x)[2:13]
})
})

bsgcm <- reactive({
x <- read.csv(text=input$textgcm, sep="\t")
describe(x)[2:13]
})

bssem <- reactive({
x <- read.csv(text=input$textsem, sep="\t")
describe(x)[2:13]
})
})

correl.cfa <- reactive({
x <- read.csv(text=input$textcfa, sep="\t")
round(cor(cbind(x), use = "complete"),3)
})
})

correl.gcm <- reactive({
x <- read.csv(text=input$textgcm, sep="\t")
round(cor(cbind(x), use = "complete"),3)
})

correl.sem <- reactive({
x <- read.csv(text=input$textsem, sep="\t")
round(cor(cbind(x), use = "complete"),3)
Expand All @@ -39,7 +39,7 @@ shinyServer(function(input, output) {
x <- read.csv(text=input$textcfa, sep="\t")
pairs.panels(x)
}

makecorPlot.gcm <- function(){
x <- read.csv(text=input$textgcm, sep="\t")
pairs.panels(x)
Expand All @@ -52,77 +52,77 @@ shinyServer(function(input, output) {
output$corPlot.cfa <- renderPlot({
print(makecorPlot.cfa())
})

output$corPlot.gcm <- renderPlot({
print(makecorPlot.gcm())
})

output$corPlot.sem <- renderPlot({
print(makecorPlot.sem())
})

get.textcfa <- reactive({
input$cfamodel
})

get.textgcm <- reactive({
input$gcmmodel
})

get.textsem <- reactive({
input$semmodel
})

est.cfa <- reactive({
dat <- read.csv(text=input$textcfa, sep="\t")

model <- get.textcfa()
fit <- cfa(model, data=dat)

fit <- cfa(model, data=dat, estimator = input$estimatoroptions, se = input$seoptions, bootstrap = input$bootstrapoptions)

list(fit = fit)
})

est.gcm <- reactive({
dat <- read.csv(text=input$textgcm, sep="\t")

model <- get.textgcm()

fit <- growth(model, data=dat, estimator = input$estimatoroptions, se = input$seoptions, bootstrap = input$bootstrapoptions)

list(fit = fit)
})

est.sem <- reactive({
dat <- read.csv(text=input$textsem, sep="\t")

model <- get.textsem()

fit <- sem(model, data=dat, estimator = input$estimatoroptions, se = input$seoptions, bootstrap = input$bootstrapoptions)

list(fit = fit)
})

result.cfa <- reactive({

rescfa <- est.cfa()$fit
summary(rescfa, standardized=TRUE, fit.measures=TRUE)
})

})
result.gcm <- reactive({

resgcm <- est.gcm()$fit
summary(resgcm, standardized=TRUE, fit.measures=TRUE)

})

result.sem <- reactive({

ressem <- est.sem()$fit
summary(ressem, standardized=TRUE, fit.measures=TRUE)

})

makecfaplot1 <- function(){
rescfa <- est.cfa()$fit
semPaths(rescfa, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
Expand All @@ -131,53 +131,53 @@ shinyServer(function(input, output) {
resgcm <- est.gcm()$fit
semPaths(resgcm, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
}

makesemplot1 <- function(){
ressem <- est.sem()$fit
semPaths(ressem, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
}
}

output$cfaplot1 <- renderPlot({
print(makecfaplot1())
})

output$gcmplot1 <- renderPlot({
print(makegcmplot1())
})

output$semplot1 <- renderPlot({
print(makesemplot1())
})

makegcmplot2 <- function(){
resgcm <- est.gcm()$fit
semPaths(resgcm, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
}
makecfaplot2 <- function(){
rescfa <- est.cfa()$fit
semPaths(rescfa, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
}
}

makesemplot2 <- function(){
ressem <- est.sem()$fit
semPaths(ressem, "par", mar=c(3,4,3,4), style="ram", layout ="tree", edge.label.cex=.8, fade=F, gray=T)
}
}

output$cfaplot2 <- renderPlot({
print(makecfaplot1())
})
})

output$gcmplot2 <- renderPlot({
print(makegcmplot1())
})

output$semplot2 <- renderPlot({
print(makesemplot1())
})
################################################
# R session info
################################################

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 = "")
Expand All @@ -197,7 +197,7 @@ shinyServer(function(input, output) {
cat(sprintf(info5), "\n")
cat(sprintf(info6), "\n")
})

# 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 = "")
Expand All @@ -206,47 +206,47 @@ shinyServer(function(input, output) {
# })
output$info.cfa <- renderPrint({
info()
})
})
output$info.gcm <- renderPrint({
info()
})

output$info.sem <- renderPrint({
info()
})

output$textareacfa <- renderPrint({
bscfa()
})

output$textareagcm <- renderPrint({
bsgcm()
})

output$textareasem <- renderPrint({
bssem()
})

output$correl.cfa <- renderPrint({
correl.cfa()
})

output$correl.gcm <- renderPrint({
correl.gcm()
})

output$correl.sem <- renderPrint({
correl.sem()
})

output$result.cfa <- renderPrint({
result.cfa()
})

output$result.gcm <- renderPrint({
result.gcm()
})

output$result.sem <- renderPrint({
result.sem()
})
Expand Down

0 comments on commit 720efe5

Please sign in to comment.