Spaces:
Sleeping
Sleeping
File size: 3,534 Bytes
3e4571e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
library(shiny)
source('var.test.R')
shinyServer(function(input,output,session){
observe({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header,
sep=input$sep)
updateSelectInput(session, "variable", choices=names(dt))
})
output$statistic <- renderTable({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header,
sep=input$sep)
y <- na.omit(dt[, input$variable]) # Para sacar los NA de la variable
res <- data.frame(Min=min(y), Var=var(y),
Max=max(y), n=length(y))
colnames(res) <- c('Mínimo', 'Varianza', 'Máximo', 'Número obs')
res
}, align='c', bordered=TRUE)
output$appPlot <- renderPlot({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header, sep=input$sep)
par(mfrow=c(1, 2), bg='gray98')
y <- na.omit(dt[, input$variable]) # Para sacar los NA de la variable
hist(y, col='deepskyblue3', freq=F, las=1,
xlab=as.character(input$variable),
main='Histograma y densidad', ylab='Densidad')
lines(density(y), lwd=4, col='firebrick3')
qqnorm(y, las=1, main='QQplot',
pch=19, col='deepskyblue3',
ylab=as.character(input$variable))
qqline(y)
ks <- ks.test(x=y, y=pnorm)
legend('topleft', bty='n', col='red', text.col='deepskyblue3',
legend=paste('Valor P=', round(ks$p.value,2)))
})
output$inputData <- renderTable({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header,
sep=input$sep)
dt
})
output$resul1 <- renderText({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header,
sep=input$sep)
y <- na.omit(dt[, input$variable]) # Para sacar los NA de la variable
ph <- var.test(x=y, alternative=input$h0,
null.value=input$sigma20,
conf.level=input$alfa)
paste0('El estadístico de prueba es ', round(ph$statistic, 2),
' con un valor-P de ', round(ph$p.value, 4), '.')
})
output$resul2 <- renderText({
inFile <- input$file1
if(is.null(inFile))
dt <- read.table('var_data.txt', header=T, sep='\t')
else dt <- read.csv(inFile$datapath, header=input$header,
sep=input$sep)
y <- na.omit(dt[, input$variable]) # Para sacar los NA de la variable
ph <- var.test(x=y, alternative=input$h0,
null.value=input$sigma20,
conf.level=input$alfa)
intervalo <- paste("(", round(ph$conf.int[1], digits=4), ", ",
round(ph$conf.int[2], digits=4), ").", sep='')
paste0('El intervalo de confianza del ', 100*input$alfa,
'% para la varianza poblacional es ', intervalo)
})
output$miteoria <- renderUI({
HTML(markdown::markdownToHTML(knit(input='include.md', quiet=TRUE)))
})
})
|