## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
# Print enough significant digits that values like `10.46` are not
# abbreviated to `10.5` in the output tibbles:
options(pillar.sigfig = 4)

## ----setup, include = FALSE---------------------------------------------------
library(scrutiny)

## -----------------------------------------------------------------------------
flights1 <- tibble::tribble(
  ~x    ,
   8.97 ,
   2.61 ,
   7.26 ,
   3.64 ,
   9.26 ,
  10.46 ,
   7.39 ,
)

## -----------------------------------------------------------------------------
flights1 <- flights1 |>
  dplyr::mutate(n = 28)

flights1

## -----------------------------------------------------------------------------
flights2 <- tibble::tribble(
  ~drone        , ~selfpilot    ,
  "0.09 (0.28)" , "0.19 (0.39)" ,
  "0.19 (0.39)" , "0.53 (0.50)" ,
  "0.62 (0.49)" , "0.5 (0.50)"  ,
  "0.15 (0.31)" , "0.57 (0.50)" ,
)

flights2 |>
  split_by_parens()

## -----------------------------------------------------------------------------
flights2 |>
  split_by_parens(transform = TRUE)

## -----------------------------------------------------------------------------
flights2 |>
  split_by_parens(transform = TRUE) |>
  dplyr::mutate(
    n = 80,
    digits_x = decimal_places(x),
    digits_sd = decimal_places(sd),
    x = as.numeric(x),
    sd = as.numeric(sd)
  ) |>
  debit_map(data_type = "integer")

## -----------------------------------------------------------------------------
flights2 |>
  split_by_parens(end1 = "beta", end2 = "se")

## -----------------------------------------------------------------------------
flights2 |>
  split_by_parens(end1 = "beta", end2 = "se", transform = TRUE)

## -----------------------------------------------------------------------------
flights3 <- flights2 |>
  dplyr::pull(selfpilot)

flights3

flights3 |>
  before_parens()

flights3 |>
  inside_parens()

## -----------------------------------------------------------------------------
flights1_with_issues <- flights1 |>
  dplyr::mutate(x = as.character(x), n = as.character(n)) |>
  tibble::add_row(x = "x", n = "n", .before = 1)

colnames(flights1_with_issues) <- c("Var1", "Var2")

flights1_with_issues

## -----------------------------------------------------------------------------
flights1_with_issues |>
  row_to_colnames()

