The lib_write
function writes the data library
to the file system. The library will be written to the
directory for which it was defined, and each data frame will be written
in the format associated with the library data engine. See the
libname
function for further elaboration on the types
of engines available, and the assumptions/limitations of each.
By default, the lib_write
function will not write data that has
not changed. Prior to writing a file, lib_write
will compare the
data in memory to the data on disk. If there are differences in the data,
the function will overwrite the version on disk. To override the default
behavior, use the force
option to force lib_write
to write
every data file to disk.
Note that writing sas7bdat files to disk is not supported.
lib_write(x, force = FALSE)
The saved data library.
Other lib:
is.lib()
,
lib_add()
,
lib_copy()
,
lib_delete()
,
lib_export()
,
lib_info()
,
lib_load()
,
lib_path()
,
lib_remove()
,
lib_replace()
,
lib_size()
,
lib_sync()
,
lib_unload()
,
libname()
,
print.lib()
# Create temp directory
tmp <- tempdir()
# Create library
libname(dat, tmp)
# # library 'dat': 0 items
# - attributes: rds not loaded
# - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
# NULL
# Load the empty library
lib_load(dat)
# Add data to the library
dat.mtcars <- mtcars
dat.beaver1 <- beaver1
dat.iris <- iris
# Unload the library
lib_unload(dat)
# library 'dat': 3 items
# - attributes: rds not loaded
# - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
# - items:
# Name Extension Rows Cols Size LastModified
# 1 beaver1 NA 114 4 4.6 Kb <NA>
# 2 iris NA 150 5 7.1 Kb <NA>
# 3 mtcars NA 32 11 7 Kb <NA>
# Write the library to the file system
lib_write(dat)
# library 'dat': 3 items
#- attributes: not loaded
#- path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
#- items:
# Name Extension Rows Cols Size LastModified
#1 beaver1 rds 114 4 4.8 Kb 2020-11-05 20:47:16
#2 iris rds 150 5 7.3 Kb 2020-11-05 20:47:16
#3 mtcars rds 32 11 7.3 Kb 2020-11-05 20:47:16
# Clean up
lib_delete(dat)