data-raw/dataset.R

# Store path to source file in url variable.

url <- paste("https://www.ngdc.noaa.gov/nndc/struts/results?type_0=",
             "Exact&query_0=$ID&t=101650&s=13&d=189&dfn=signif.txt",
             sep = "")

# Create temporary file with .txt extension.

file <- tempfile(fileext = ".txt")

# Download source data to temporary file using url.

download.file(url, file, method = "curl")

# Read file to data frame.

earthquakes <- utils::read.delim2(file,
                                  header = TRUE,
                                  sep = "\t",
                                  na.strings = c(""),
                                  stringsAsFactors = FALSE)

# Save data frame to data directory.

usethis::use_data(earthquakes, overwrite = TRUE)
dtminnick/earthquake documentation built on Nov. 4, 2019, 11:04 a.m.