-1

I am trying to create a code that would replace all missing values by user entered value(a separate value for each variable) for all variables in a dataset? Any help would be highly appreciated!! Thanks!

To be more precise, below are me questions in comment form.

if (interactive()) {



     ui <- fluidPage(
        # In place of "obs" name in UI, I want to display name as "Contact" which should be read directly as 4th column of data frame
        numericInput("obs", "Age", 30, ),
        verbatimTextOutput("value")

      )
      server <- function(input, output) {
        output$value <- renderText({ input$obs })
    #I don't want to display the text in UI. Is there a feature in R Shiny which stores the input$obs in data table?
      }
      shinyApp(ui, server)
    }
Mal_a
  • 3,670
  • 1
  • 27
  • 60
  • 1
    What have you done so far? – Borjante Mar 02 '17 at 10:16
  • I am new to R,Rshiny and have very basic query. I want to create numeric input boxes with names as names of all columns. I was trying to create the below code with name of input box as "contact". But this code doesn't work. Any suggestions on how to approach this. Also, after creating the numeric box, i want to store the values entered by user in ui to a data table. I couldn't find any feature that does this. – shivani gupta Mar 06 '17 at 04:53
  • library(shiny) data_set = data.frame(Name = c ("ABC","ABC","ABC","DEF"), Country = c("US, Japan","US, Japan","US, Japan","Canada, US","Canada, US", "UK, US", "UK, US", "Germany"), Region = c("AMR, Asia","North America, Asia","AMR, Asia","North America","AMR"), Contact = c(1234,1234,1234,7578), ContactPerson = c("Geoff","Mary","Mike","Don")) if (interactive()) {shinyApp( ui = fluidPage( verbatimTextOutput("value")), server = function(input, output) { output$value <- renderText({ paste("You chose", input$criteria) }))} – shivani gupta Mar 06 '17 at 04:56
  • first of all You should move this chunk of code above to Your question and not answer!Properly formatted...And eitherway Your piece of code is producing only Errors, you should have a look on the post http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Mal_a Mar 06 '17 at 08:36

1 Answers1

1

Here is an example code which can put You in the right track, for the future i recommend to create good reproducible example (Link) so it is going to help easier and faster solve the question.

library(shiny)
library(DT)

x <- c(1,2, NA)
y <- c(1:3)
data <- data.frame(x,y)

ui= basicPage(
  selectInput("value_na", "Choose value:", choices = c(3,4), selected=3), #Here you can choose the value which is going to replace Na's,
  dataTableOutput("tab"),
  dataTableOutput("tab2"))

server= function(input, output,session) {

  output$tab <-  DT::renderDataTable({datatable(data,options=list(bFilter=FALSE, bPaginate=FALSE))})

  data2 <- reactive({
  data$x[is.na(data$x)] <-input$value_na
  data})

  output$tab2 <-  DT::renderDataTable({datatable(data2(),options=list(bFilter=FALSE, bPaginate=FALSE))})
}

shinyApp(ui, server)
Community
  • 1
  • 1
Mal_a
  • 3,670
  • 1
  • 27
  • 60