Skip to content

Instantly share code, notes, and snippets.

@sumanstats
Last active April 22, 2020 05:21
Show Gist options
  • Save sumanstats/59db41e77edc7802a1e5a21a1239505d to your computer and use it in GitHub Desktop.
Save sumanstats/59db41e77edc7802a1e5a21a1239505d to your computer and use it in GitHub Desktop.
function to document dataset
document_data <- function(dataset,R_file) {
initial = "#' WHAT IS THIS DATASET ABOUT
#'
#' WRITE DESCRIPTION OF THIS DATASET
#'
#'
#' @usage HOW TO USE
#'
#' @format Description
#' \\describe{"
middle=paste0("#' ","\\item{",names(dataset),"}","{}")
last = paste0("#' }
\"",deparse(substitute(dataset)),"\"")
write(c(initial,middle,last),R_file)
}
# You can read csv with encoding UTF-8, this way it correctly shows nepali characters
file <- readr::read_csv("<data>.csv",
locale = readr::locale(encoding = "UTF-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment