| rtry_import | R Documentation |
This function imports a data file as a data.table for further processing.
The default arguments are set to import tabulartor delimited data files in text
format (.txt) exported from the TRY database. It can also be used to
import other file formats, such as .csv files with comma separated values.
rtry_import(
input,
separator = "\t",
encoding = "Latin-1",
quote = "",
showOverview = TRUE
)
input |
Path to the data file. |
separator |
Default |
encoding |
Default |
quote |
Default |
showOverview |
Default |
A data.table.
This function makes use of the fread function
within the data.table package.
# Example 1: Import data exported from the TRY database
# Specify file path to the raw data provided within the rtry package
input_path <- system.file("testdata", "data_TRY_15160.txt", package = "rtry")
# For own data and Windows users the path might rather look similar to this:
# input_path <- "C:/Users/User/Desktop/data_TRY_15160.txt"
# Import data file using rtry_import
input <- rtry_import(input_path)
# Explicit notation:
# input <- rtry_import(input_path, separator = "\t", encoding = "Latin-1",
# quote = "", showOverview = TRUE)
# Expected message:
# input: ~/R/R-4.0.5/library/rtry/testdata/data_TRY_15160.txt
# dim: 1782 28
# col: LastName FirstName DatasetID Dataset SpeciesName AccSpeciesID AccSpeciesName
# ObservationID ObsDataID TraitID TraitName DataID DataName OriglName
# OrigValueStr OrigUnitStr ValueKindName OrigUncertaintyStr UncertaintyName
# Replicates StdValue UnitName RelUncertaintyPercent OrigObsDataID ErrorRisk
# Reference Comment V28
# Example 2: Import CSV file
# Specify file path to the raw data provided within the rtry package
input_path <- system.file("testdata", "data_locations.csv", package = "rtry")
# Import data file using rtry_import
input <- rtry_import(input_path, separator = ",", encoding = "UTF-8",
quote = "\"", showOverview = TRUE)
# Expected message:
# input: ~/R/R-4.0.5/library/rtry/testdata/data_locations.csv
# dim: 20 3
# col: Country code Country Location
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.