Read Data Frame or Object from qs File in a Specified Directory
Source:R/here_read_qs.R
here_read_qs.Rd
Reads a `.qs` file specified by `name` from a directory defined by `dir_path`, returning the data frame or object stored within. This function uses the `qs` package to efficiently read `.qs` files and the `here` package to construct the file path in a consistent, platform-independent manner.
Arguments
- name
Character string specifying the name of the `.qs` file to be read (without the ".qs" extension).
- dir_path
Character string specifying the directory path from which the file will be read. If NULL (default), uses `push_mods`.
- nthreads
Integer specifying the number of threads to use for decompression. Default is 1.
- quiet
Logical. If TRUE, suppresses console output. Default is FALSE.
Details
If `dir_path` is NULL, the `push_mods` variable must be defined in the user's environment or within the package, pointing to the directory from where files are to be read. This function will throw an error if the specified file does not exist or cannot be read as a `.qs` file.
Examples
# Assuming `push_mods` is set in your environment to "~/mydata"
# and you have previously saved a `.qs` file named "my_dataset.qs" in that directory
my_df <- here_read_qs("my_dataset")
#> Error in here_read_qs("my_dataset"): object 'push_mods' not found
# Reading from a custom directory with multiple threads
my_df <- here_read_qs("my_dataset", dir_path = "~/custom_dir", nthreads = 4)
#> Error in here_read_qs("my_dataset", dir_path = "~/custom_dir", nthreads = 4): File not found: ~/custom_dir/my_dataset.qs