Error ValueBox: Text to be written must be a length one character

Hi,
I have a Value Box and I want to show the minimum of that variable including the country and the year where that minimum was registered.
In some variables, that minimum is repetead and it gives the error:

Do you know any function that solve this problem or maybe just don't show anything if the value is repeated?
The code is:

Highlight 1 {.value-box}

number1 <- reactive({ 
    global %>% 
    select(input$var1, pais, ano) %>% 
    rename(Y1 = input$var1) %>% 
    summarise(Min = min(Y1, na.rm=TRUE),
              pais1 = global[Y1 == Min, "pais"],
              ano1 = global[Y1 == Min, "ano"]) 
})
renderValueBox({
  rate2=as.character(number1()$pais1)
  rate3=as.character(number1()$ano1)
  caption1<- paste("Valor mínimo:",
                   rate2, "em", rate3)
  rate1=as.numeric(number1()$Min)
  valueBox(
    value = round(rate1,digits=2),
    color = "teal",
    icon = "fa-arrow-down",
    caption = caption1
  )
})

Thanks a lot!

You can use the head function with parameter n set to 1 to pick the first of something

It worked, thanks a lot!!!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.