R/utils.R

Defines functions is_data.table is_tibble is_rstudio_selection first_row_to_header

first_row_to_header <- function(a_table){
  colnames(a_table) <- a_table[1, , drop = FALSE]
  colnames(a_table) <- gsub(" ", ".", colnames(a_table))
  a_table <- a_table[-1, , drop = FALSE]
  rownames(a_table) <- seq(nrow(a_table))
  a_table
}

is_rstudio_selection <- function(){
  context <- rstudioapi::getActiveDocumentContext()
  !all(context$selection[[1]]$range$start ==
         context$selection[[1]]$range$end)
}

is_tibble <-  function(x) inherits(x, "tbl_df")

is_data.table <- function(x) inherits(x, "data.table")

Try the datapasta package in your browser

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

datapasta documentation built on April 17, 2020, 1:27 a.m.