The lib_copy function copies a data library. The function accepts a library and a destination path. If the destination path does not exist, the function will attempt to create it.

Note that the copy will result in the current data in memory written to the new destination directory. If the library is loaded into the workspace, the workspace version will be considered the most current version, and that is the version that will be copied.

lib_copy(x, nm, directory_path, standard_eval = FALSE)



The library to copy.


The unquoted variable name to hold the new library. The parameter will assume non-standard (unquoted) evaluation unless the standard_eval parameter is set to TRUE.


The path to copy the library to.


A TRUE or FALSE value which indicates whether to use standard (quoted) or non-standard (unquoted) evaluation on the nm parameter. Default is FALSE. Use this parameter if you want to pass the target library name in a variable.


The new library.

See also


# Create temp directory
tmp <- tempdir()

# Create library
libname(dat1, tmp)

# Add dat to library
lib_add(dat1, mtcars, iris)

# Copy dat1 to dat2
lib_copy(dat1, dat2, file.path(tmp, "copy"))
# library 'dat2': 2 items
# - attributes: not loaded
# - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc/copy
# - items:
#     Name Extension Rows Cols   Size        LastModified
# 1 mtcars       rds   32   11 7.5 Kb 2020-11-05 21:14:54
# 2   iris       rds  150    5 7.5 Kb 2020-11-05 21:14:54

# Clean up