Hi,
I'm building a shiny app that uses the rhandson package. I want to make one column editable but also make sure none of the cells can be left empty. I used the following code
table= reactive({
a= levels(object$column)
b=vector(mode="character",length(a))
df=data.frame(a,b,stringsAsFactors = F)
colnames(df)=c("A","B")
return(df)
})
#Create datatable to enter values to B and process it to reset table
output$df= renderRHandsontable({
table=table()
rhandsontable(as.data.frame(table)) %>% hot_col("A",readOnly=TRUE)
})
I can use a validate statement to make sure the number of elements in B are equal to A like this
validate(need(length(input$df$data$B)==length(input$df$data$A),"Please enter missing values for B "))
But this doesn't work. length(input$df$data$B) always returns same length. Lets say number of rows in the table is 10.length(as.character(input$df$data$B[is.na(input$df$data$B)==F])) also, for some reason, is returning 10.
Is there anyway we can count empty cells in rhandsontable ? Or is there is a way to force the table to enter values and not leave it blank?
Can you please clarify how this is related to bioinformatics? Looks like pure programming on first sight.