R/posit.R

Defines functions is_rstudio_notebook is_positron is_rstudio

is_rstudio <- function() {
  identical(Sys.getenv("RSTUDIO"), "1")
}

is_positron <- function() {
  identical(Sys.getenv("POSITRON"), "1")
}

is_rstudio_notebook <- function() {
  flag <- FALSE
  # inline doesn't work in Positron
  if (is_rstudio()) {
    assert_dependency("rstudioapi")
    con <- rstudioapi::getActiveDocumentContext()[["path"]]
    if (isTRUE(grepl("\\.qmd$|\\.Rmd$", con))) {
      flag <- TRUE
    }
  }
  return(flag)
}

Try the tinytable package in your browser

Any scripts or data that you put into this service are public.

tinytable documentation built on April 3, 2025, 7:43 p.m.