lib_copy: Copy a Data Library

View source: R/libname.R

lib_copyR Documentation

Copy a Data Library

Description

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.

Usage

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

Arguments

x

The library to copy.

nm

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

directory_path

The path to copy the library to.

standard_eval

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.

Value

The new library.

See Also

Other lib: is.lib(), lib_add(), lib_delete(), lib_export(), lib_info(), lib_load(), lib_path(), lib_remove(), lib_replace(), lib_size(), lib_sync(), lib_unload(), lib_write(), libname(), print.lib()

Examples

# 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
lib_delete(dat1)
lib_delete(dat2)

dbosak01/libr documentation built on March 19, 2024, 5:50 p.m.