Learn R Programming

Introduction to libr

R is a very flexible and powerful language. But there are some inconveniences when working with data:

  1. Loading many related datasets: When you have many data files

that are related in some way, it is troublesome when you want to use them all in your analysis. Most data import packages make you load each file individually. And the thing is, almost all data comes in sets of related files. So you would think that there would be an easy mechanism to load them all at once.

  1. Examining the Attributes of Your Data: Once you have a set of related

data files loaded into your program, the next problem is how to examine the structure of all of them. R has the str() function if you want to understand the structure of a single dataset. But what if there are many? There is no simple way to examine the attributes of many related datasets. And further, some valuable attributes are missing from the str() function output.

  1. Row-By-Row Processing of Data: R processes data column by column.

In most cases, column-by-column is a perfectly suitable way of processing data. But in some cases it is desirable to process data row-by-row. Row-by-row processing is useful when you have many related columns, and want to perform complex conditional processing across them. It is also very convenient when you have grouped data, and want to perform conditional processing within a group.

Solution

The libr package was developed to address all of the above problems. It does so by introducing three concepts:

  • Data Libraries
  • Data Dictionaries
  • A Data Step

By introducing these concepts, the libr package makes working with data in R much easier and faster. The libr package can greatly simplify your data processing code. And it makes some types of data operations effortless that are quite tricky to do with Base R or even tidyverse functions.

Installation

To install the libr package, run the following command from your R console:

install.packages("libr")

Then put the following line at the top of your program or script:

library(libr)

The libr package will then be ready to use! For examples and usage information, please visit the libr documentation site here

Getting Help

If you need help, the first place to turn to is the libr web site. The web site has full documentation on all libr functions.

If you want to look at the code for the libr package, visit the github page here.

If you encounter a bug or have a feature request, please submit an issue here.

See Also

The libr package is part of the sassy meta-package. The sassy meta-package includes several packages that help make R easier for everyone, especially people with a background in SASĀ® software. You can read more about the sassy package here.

Copy Link

Version

Install

install.packages('libr')

Monthly Downloads

590

Version

1.3.9

License

CC0

Issues

Pull Requests

Stars

Forks

Maintainer

David Bosak

Last Published

January 12th, 2025

Functions in libr (1.3.9)

is.lib

Class test for a data library
length.dsarray

Length function for dsarray class
lib_sync

Synchronize Loaded Library
libr

Libnames, Data Dictionaries and Data Steps
print.lib

Print a data library
lib_unload

Unload a Library from the Workspace
[.dsarray

Indexer for Data Step Array
print.specs

Print import specifications
specs

Create an Import Spec Collection
read.specs

Read import specs from the file system
lib_copy

Copy a Data Library
lib_info

Get Information about a Data Library
lib_load

Load a Library into the Workspace
lib_write

Write a Data Library to the File System
libname

Create a data library
write.specs

Write import specs to the file system
output

Outputs an observation from a datastep
lib_add

Add Data to a Data Library
dsattr

Assign Datastep Variable Attributes
delete

Removes an observation from a datastep
lib_size

Get the Size of a Data Library
dictionary

Create a Data Dictionary
import_spec

Create an Import Specification
datastep

Step through data row-by-row
lib_replace

Replace Data in a Data Library
dsarray

Create a Data Step Array
lib_export

Export a Data Library
lib_delete

Delete a Data Library
lib_path

Get the Path for a Data Library
lib_remove

Remove Data from a Data Library