Count empty rows in Rhandsontable
0
0
Entering edit mode
5.6 years ago
AB ▴ 360

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?

rhandsontable shiny • 1.4k views
ADD COMMENT
0
Entering edit mode

Can you please clarify how this is related to bioinformatics? Looks like pure programming on first sight.

ADD REPLY

Login before adding your answer.

Traffic: 2350 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6