I have a problem with my shiny code, I want to make a conditional that tells me the na of each column of a dataframe and that shows me the columns that meet the condition that the na are greater than 30 percent of the total rows
ui <- dashboardPage(
dashboardHeader(title = titulo, titleWidth = 250, disable= F
),#header
dashboardSidebar(width = 250, disable = F,
fluidPage(
sidebarMenu(
menuItem("Carga",tabName = "carga", icon = icon("upload")),
menuItem("Selección",tabName = "selec")
)#sidebarMenu
)# fluidPage
), #dashboardSidebar
dashboardBody(
fluidPage(
tabItems(
tabItem(tabName = "carga",
tabPanel(strong("Ingreso"),
h3("Carga de Datos"),
tags$hr(),
fluidRow(
column(5,
selectInput("separador",
h4("Separador"),
choices = list(" , " = ",",
" ; " = ";",
"Seleccione una opción"= 3
),
selected = 3
),
# tags$hr(),
checkboxInput("header", "Encabezado", TRUE),
selectInput("codificar",
h4("Elegir codificación"),
choices = list("Seleccione una opción"= 3,
" ISO-8859-1 " = "ISO-8859-1",
" UTF-8 " = "UTF-8",
" ASCII " = "ASCII",
" BIG5" = "BIG5",
" GB18030 " = "GB18030",
" GB2312 " = "GB2312",
" ISO-2022-JP " = "ISO-2022-JP",
" ISO-2022-KR " = "ISO-2022-KR",
" ISO-8859-2 " = "ISO-8859-2",
" ISO-8859-7 " = "ISO-8859-7",
" SHIFT-JIS " = "SHIFT-JIS",
" WINDOWS-1252 " = "WINDOWS-1252"
),
selected = 3
)
),#column
column(5,
fileInput("fichero",
h4("Archivo"),
buttonLabel = "Fichero",
placeholder = "selecciona un fichero",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
),
multiple = F)
)#column
)#fluidrown
) #tabpanel ingreso
),#carga
tabItem(tabName = "selec",
tabPanel(strong("Tabla"),
sidebarLayout(
sidebarPanel(
uiOutput("uiSeleccion"),
),
mainPanel(
br(),
box( height = "500",width = "15",solidHeader = T,
dataTableOutput("tabla1"),style = "height:500px; overflow-y: scroll;overflow-x: scroll;"
)#BOX
)#mainPanel
)#sidebarLayout
)#tabpanel seleccion
)#tabItem seleccion
)#tabItems
)#fluidpage
)#dashboardBody
)#dashboardPage
server <- function(input, output, session) {
####-------------RENDER DE FILEINPUT CARGA ---------------------
archivo1 <- reactive({
file <- input$fichero
if (is.null(file)|| input$separador == 3)
return(NULL)
archivo <- read.csv(file$datapath,
sep = input$separador,
header = input$header,
encoding = input$codificar,
na = c("", "NA"),
stringsAsFactors = F
)
})
####------------ RENDER DE SELECCION-----------------------------------
####------------ render seleccion checkbox
#faq-discussion
output$uiSeleccion <- renderUI({
checkboxGroupInput("variables", "Columnas del dataset para mostrar:",
names(archivo1()), selected = names(archivo1()))
})
####------------ render archivo de seleccion
archivo2 <- reactive({
archivo1()[ ,input$variables, drop = F
]})
####------------ render tabla de seleccion
output$tabla1 <- renderDataTable({
DT::datatable(archivo2())
})
}