-
Help
DescriptionIs it possible to load a stantargets object from outside of a targets directory? For example, with other targets files in the _targets/objects folder , I can load these using readRDS(). However, whenever I try this with files generated by stantargets (e.g., summary or draws objects), I receive an error stating "unknown input format". # Make a temp directory
temp <- tempdir()
# Link to a targets object created by targets
stantargets_object <- "https://github.com/AdamWilsonLab/emma_model/raw/targets-runs/_targets/objects/model_output_data_e4183434"
# Link to a targets object created by stantargets
targets_object <- "https://github.com/AdamWilsonLab/emma_model/raw/targets-runs/_targets/objects/dyndata_training"
# Download files to temp dir
download.file(url = stantargets_object,
destfile = file.path(temp,basename(stantargets_object)))
download.file(url = targets_object,
destfile = file.path(temp,basename(targets_object)))
# Attempt to load files:
readRDS(file.path(temp, basename(stantargets_object))) #"Unknown input format"
#> Error in readRDS(file.path(temp, basename(stantargets_object))): unknown input format
readRDS(file.path(temp, basename(targets_object)))|>
head() # Works fine
#> cellID date most_recent_burn_date ndvi time_since_fire age
#> 1 2895983 2000-12-01 0 NA NA NA
#> 2 2895985 2000-12-01 0 NA NA NA
#> 3 2895986 2000-12-01 0 NA NA NA
#> 4 2898019 2000-12-01 0 NA NA NA
#> 5 2898020 2000-12-01 0 NA NA NA
#> 6 2900051 2000-12-01 0 NA NA NA Created on 2023-07-21 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
My recommendation at ropensci/targets#1097 (reply in thread) would help if the files are local, but it looks like you are loading it from a GitHub repo. Also, If you want to store the data remotely and access it locally, you could use built-in cloud storage: https://books.ropensci.org/targets/data.html#cloud-storage |
Beta Was this translation helpful? Give feedback.
My recommendation at ropensci/targets#1097 (reply in thread) would help if the files are local, but it looks like you are loading it from a GitHub repo. Also,
stantargets
usesformat = "qs"
andformat = "fst"
, so you might needqs::qread()
and/orfst::read_fst()
for the code in your comment to work.If you want to store the data remotely and access it locally, you could use built-in cloud storage: https://books.ropensci.org/targets/data.html#cloud-storage