Reputation: 9
I'm newbie in Shiny, trying to make an app where I would like to make an overall statistical analysis (on time series) based on a dataset which I prior loaded. The problem is that I do not know how to "work" with a specific variable from dataset. I would like that the variable to be taken "dynamically", something like, datos[,2], but I do not know how to do this. Now I use attach function and then set y manually. So my code for now is:
shinyServer(function(input, output) {
output$RawData <- DT::renderDataTable(
DT::datatable({
datos
},
options = list(lengthMenu=list(c(5,15,20),c('5','15','20')),pageLength=10,
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': 'moccasin', 'color': '1c1b1b'});",
"}"),
columnDefs=list(list(className='dt-center',targets="_all"))
),
# filter = "top",
# selection = 'multiple',
# style = 'bootstrap',
# class = 'cell-border stripe',
# rownames = FALSE,
# colnames = TRUE
))
testy=reactive({
attach(datos)
y=IMM
if(input$primavar==1){
probaty=adf.test(y)}
else {
if(input$primavar==2){
probaty=pp.test(y)
}
else {
probaty=kpss.test(y, null="Trend")
}}
probaty
})
output$Probay <- renderPrint({
testy()
})
output$Conclusiony <- renderText({
if(input$primavar==1 | input$primavar==2){
if(testy()$p.value < 0.05){mensaje="We reject the null hypothesis, the variable is stationary"}else{mensaje="We keep the null hypothesis, the variable is not stationary"}
mensaje}
else {
if(testy()$p.value > 0.05){mensaje="We accept the null hypothesis, the variable is stationary"}else{mensaje="We reject the null hypothesis, the variable is not stationary"}
mensaje}
})
Upvotes: 0
Views: 45
Reputation: 388982
To get the 2nd column dynamically from datos
you can use [[
.
testy=reactive({
y=datos[[2]]
....
....
....
})
Upvotes: 1