Read a downloaded dataset from an Argentine weather station
Source:R/read_datasets.R
read_datasets.RdThe read_datasets() function reads a CSV file containing meteorological data for a specific weather station.
The function loads the data into the global environment, allowing analysis and further manipulation.
Arguments
- id_station
A string representing the identifier for the desired weather station, if
pathis not provided. Valid identifiers include:"NH0472","NH0910","NH0046","NH0098", and"NH0437". This parameter is used to construct the path to the CSV file.- path
An optional string specifying the file path of the CSV file to be read. If provided,
id_stationis ignored.
Details
This function is designed to work in conjunction with download_datasets(), which downloads and saves the weather station data.
There are three ways to use this function:
Using
download_datasets()with the default path: If the file is saved in the default"datasets-raw"folder, you only need to provide theid_stationparameter to read the file.Using a custom path: If you saved the file in a custom folder, provide the complete file path using the
pathparameter.Using the return value of
download_datasets(): You can store the path returned bydownload_datasets()in a variable and pass it toread_datasets()via thepathparameter.
See also
goatR::download_datasets to download and save weather station datasets.
Examples
# Use download_datasets() with default path, then read using id_station
download_datasets("NH0472")
#> ✔ File downloaded successfully to: datasets-raw/NH0472.csv
#> [1] "datasets-raw/NH0472.csv"
data <- read_datasets(id_station = "NH0472")
#> ✔ Data loaded successfully from datasets-raw/NH0472.csv.
# Use a custom path
download_datasets("NH0910", "./custom_folder/NH0910_data.csv")
#> ✔ File downloaded successfully to: ./custom_folder/NH0910_data.csv
#> [1] "./custom_folder/NH0910_data.csv"
data <- read_datasets(path = "./custom_folder/NH0910_data.csv")
#> ✔ Data loaded successfully from ./custom_folder/NH0910_data.csv.
# Store the path from download_datasets() and use it directly in read_datasets()
file_path <- download_datasets("NH0046")
#> ✔ File downloaded successfully to: datasets-raw/NH0046.csv
data <- read_datasets(path = file_path)
#> ✔ Data loaded successfully from datasets-raw/NH0046.csv.