MyNixOS website logo
Description

A Time Input Widget for Shiny.

Provides a time input widget for Shiny. This widget allows intuitive time input in the '[hh]:[mm]:[ss]' or '[hh]:[mm]' (24H) format by using a separate numeric input for each time component. The interface with R uses date-time objects. See the project page for more information and examples.

shinyTime

R-CMD-check

Overview

shinyTime provides a timeInput widget for Shiny. This widget allows intuitive time input in the hh:mm:ss or hh:mm (24-hour) format by using a separate numeric input for each time component. Setting and getting of the time in R is done with date-time objects.

Installation

# Install from CRAN
install.packages("shinyTime")

Usage

As the shinyTime package mimics the existing shiny functionality, using the package is easy:

ui <- fluidPage(
  # Using the default time 00:00:00
  timeInput("time1", "Time:"),

  # Set to current time
  timeInput("time2", "Time:", value = Sys.time()),

  # Set to custom time 
  timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
 
  # Set to custom time using hms
  timeInput("time4", "Time:", value = hms::as_hms("23:45:07")),

  # Set to custom time using character string
  timeInput("time5", "Time:", value = "21:32:43"),

  # Use hh:mm format
  timeInput("time6", "Time:", seconds = FALSE),

  # Use multiples of 5 minutes
  timeInput("time7", "Time:", minute.steps = 5)
)

Note that setting an initial value can be done with date-time (in the same way as setting a date in dateInput can be done with a Date object), but also with an hms::hms object or character string in hh:mm:ss format.

The value retrieved will be a date-time object (POSIXlt). You need to convert it to character to be able to show the time, as the default character representation does not include time. For example:

server <- function(input, output) {
  # Print the time in hh:mm:ss everytime it changes
  observe(print(strftime(input$time1, "%T")))
  
  # Print the time in hh:mm everytime it changes
  observe(print(strftime(input$time4, "%R")))
}

For a demo, visit the online example app or try the shinyTime::shinyTimeExample() function.

Metadata

Version

1.0.3

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows