4
4
# ' List all objects stored in a workspace object and
5
5
# ' returns results as a tibble.
6
6
# ' @param x the workspace
7
- # ' @return Tibble listing workspace contents.
7
+ # ' @return Tibble object containing the following columns:
8
+ # ' - `file`: file path to stored object relative to workspace directory
9
+ # ' - `name`: name given to object upon storing
10
+ # ' - `subdir`: subdirectory of file, such as 'datasets' or 'assets'.
11
+ # ' - `type`: file type such as 'dataset', 'geospatial', 'yaml', etc...
12
+ # ' - `timestamp`: timestamp of last modification
8
13
# ' @examples
9
14
# ' library(workspace)
10
15
# ' dir_tmp <- tempfile(pattern = "ws")
13
18
# ' z <- store_dataset(x = z, dataset = mtcars, name = "mtcars")
14
19
# ' list_object_in_workspace(z)
15
20
# ' @family functions to read in a workspace
21
+ # ' @seealso [workspace] for package documentation
16
22
list_object_in_workspace <- function (x ) {
17
23
objects_descriptions <- read_objects_description(x )
18
24
objects_descriptions
@@ -26,8 +32,9 @@ list_object_in_workspace <- function(x) {
26
32
# ' in a workspace.
27
33
# ' @param x the workspace
28
34
# ' @param name name of the dataset stored in the workspace
29
- # ' @return a `tibble` if the dataset is stored as parquet, and a
30
- # ' `sf` object if it is stored as a geospatial dataset.
35
+ # ' @return A `tibble` if the dataset is stored as parquet, and a
36
+ # ' `sf` object if it is stored as a geospatial dataset
37
+ # ' (see [store_dataset()] for details).
31
38
# ' @examples
32
39
# ' library(workspace)
33
40
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -36,6 +43,7 @@ list_object_in_workspace <- function(x) {
36
43
# ' z <- store_dataset(x = z, dataset = mtcars, name = "mtcars")
37
44
# ' read_dataset_in_workspace(z, name = "mtcars")
38
45
# ' @family functions to read in a workspace
46
+ # ' @seealso [workspace] for package documentation
39
47
read_dataset_in_workspace <- function (x , name ) {
40
48
objs <- list_object_in_workspace(x )
41
49
objs <- objs [objs $ type %in% c(" dataset" , " geospatial" ), ]
@@ -85,7 +93,7 @@ read_dataset_in_workspace <- function(x, name) {
85
93
# ' Read a raster dataset stored as a TIFF file in a workspace.
86
94
# ' @param x the workspace object
87
95
# ' @param name name of the raster dataset stored in the workspace
88
- # ' @return a `splatRaster` object
96
+ # ' @return The `splatRaster` object that was stored in TIFF format.
89
97
# ' @examples
90
98
# ' library(workspace)
91
99
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -98,6 +106,7 @@ read_dataset_in_workspace <- function(x, name) {
98
106
# ' retrieved_raster
99
107
# ' }
100
108
# ' @family functions to read in a workspace
109
+ # ' @seealso [workspace] for package documentation
101
110
read_raster_in_workspace <- function (x , name ) {
102
111
103
112
if (! requireNamespace(" terra" , quietly = TRUE )) {
@@ -146,7 +155,7 @@ read_raster_in_workspace <- function(x, name) {
146
155
# ' @param x the workspace
147
156
# ' @param name name of the object stored in the workspace
148
157
# ' @param subdir Optional subdirectory used for the asset to retrieve
149
- # ' @return the R object
158
+ # ' @return the R object that was stored as an Rds file.
150
159
# ' @examples
151
160
# ' library(workspace)
152
161
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -161,6 +170,7 @@ read_raster_in_workspace <- function(x, name) {
161
170
# ' )
162
171
# ' read_rds_in_workspace(z, name = "obj")
163
172
# ' @family functions to read in a workspace
173
+ # ' @seealso [workspace] for package documentation
164
174
read_rds_in_workspace <- function (x , name , subdir = NULL ) {
165
175
objs <- list_object_in_workspace(x )
166
176
objs <- objs [objs $ type %in% " rds" , ]
@@ -188,7 +198,7 @@ read_rds_in_workspace <- function(x, name, subdir = NULL) {
188
198
# ' @param x the workspace
189
199
# ' @param name name associated with the json file stored in the workspace
190
200
# ' @param subdir Optional subdirectory used for the asset to retrieve
191
- # ' @return a character string containing the JSON string.
201
+ # ' @return A character string containing the JSON string.
192
202
# ' @examples
193
203
# ' library(workspace)
194
204
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -209,6 +219,7 @@ read_rds_in_workspace <- function(x, name, subdir = NULL) {
209
219
# ' )
210
220
# ' read_json_str_in_workspace(z, "an_example")
211
221
# ' @family functions to read in a workspace
222
+ # ' @seealso [workspace] for package documentation
212
223
read_json_str_in_workspace <- function (x , name , subdir = NULL ) {
213
224
objs <- list_object_in_workspace(x )
214
225
objs <- objs [objs $ type %in% " json" , ]
@@ -242,7 +253,7 @@ read_json_str_in_workspace <- function(x, name, subdir = NULL) {
242
253
# ' @param x the workspace
243
254
# ' @param name name associated with the YAML file stored in the workspace
244
255
# ' @param subdir Optional subdirectory used for the asset to retrieve
245
- # ' @return a list
256
+ # ' @return A list object as read from the stored YAML file.
246
257
# ' @examples
247
258
# ' library(workspace)
248
259
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -268,6 +279,7 @@ read_json_str_in_workspace <- function(x, name, subdir = NULL) {
268
279
# ' )
269
280
# ' read_yaml_in_workspace(z, "app_config", subdir = "configs")
270
281
# ' @family functions to read in a workspace
282
+ # ' @seealso [workspace] for package documentation
271
283
read_yaml_in_workspace <- function (x , name , subdir = NULL ) {
272
284
273
285
objs <- list_object_in_workspace(x )
@@ -295,14 +307,15 @@ read_yaml_in_workspace <- function(x, name, subdir = NULL) {
295
307
296
308
297
309
# ' @export
298
- # ' @title Read Timestamp associated with a content of a Workspace .
310
+ # ' @title Read Timestamp associated with an object in a workspace .
299
311
# ' @description
300
- # ' Read a timestamp associated with a content located in a Workspace .
312
+ # ' Read a timestamp associated with an object in a workspace .
301
313
# ' @param x the workspace
302
314
# ' @param name name of the object stored in the workspace
303
315
# ' @param type content type
304
316
# ' @param subdir Optional subdirectory used for the asset to retrieve
305
- # ' @return character string of timestamp
317
+ # ' @return A character string corresponding to the timestamp (date last modified)
318
+ # ' of the stored object.
306
319
# ' @examples
307
320
# ' library(workspace)
308
321
# ' dir_tmp <- tempfile(pattern = "ws")
@@ -317,6 +330,7 @@ read_yaml_in_workspace <- function(x, name, subdir = NULL) {
317
330
# ' )
318
331
# ' read_timestamp(z, name = "obj", type = "rds", subdir = "r-object")
319
332
# ' @family functions to read in a workspace
333
+ # ' @seealso [workspace] for package documentation
320
334
read_timestamp <- function (x , name , type , subdir = NULL ) {
321
335
objs <- list_object_in_workspace(x )
322
336
objs <- objs [objs $ type %in% type , ]
0 commit comments