Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

Avoid datatable greying out when recalculating

$
0
0

I have a very simple Shiny app to show the CPU usage and available memory of the shiny server :

ui <- fluidPage(
  titlePanel('Shiny Server Monitor'),
  DT::dataTableOutput("cpu")
)

server <- function(input, output, session) {


  output$cpu <- DT::renderDataTable({
     invalidateLater(1000)

    system("free -h > top.log")
    system("uptime > uptime.log")

    free <- readLines("top.log")
    uptime <- readLines("uptime.log")

    mem = strsplit(free, "")
    available_mem =tail(mem[[2]],n=1)

    # I have 6 cores so normalized by deviding the load avarage to 6.
    load_ave = round(as.numeric(unlist(strsplit(unlist(strsplit(uptime, ","))[4],":"))[2])/6*100,2)

    dat = data.frame(load_ave,available_mem)
    colnames(dat) = c("CPU usage [%]", "Available memory [Gb]")


    DT::datatable(dat,rownames= FALSE)

  }) 

}

Since I'm using the invalidateLater command the output table is updating every second and therefore is blinking, which make everything very ugly.

Is there a way to fix this issue or present the result (especially the CPU usage) as htop command in Linux like : enter image description here


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>