Learn R Programming

⚠️There's a newer version (1.3.9) of this package.Take me there.

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.

  1. Comparison Operator: Once you are comparing two

columns of data, you run into the next inconvenience: the R comparison operator (==). This operator is highly susceptible to crashing. All you need is one NA value in one of the columns, and the comparison will crash. Since NA values are so frequently encountered in data, it would convenient if there were an infix operator that didn't crash when it encountered an aberrant value.

Solution

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

  • Data Libraries
  • Data Dictionaries
  • A Data Step
  • An Enhanced Equality Operator

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

Development Version

The libr package is under active development. If you want the latest development version, you can download it from github with the following command line:

devtools::install_github("https://github.com/dbosak01/libr")

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 need additional help, please consult stackoverflow.com. The stackoverflow community will be very willing to answer your questions.

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 SAS® programmers. You can read more about the sassy package here.

Copy Link

Version

Install

install.packages('libr')

Monthly Downloads

590

Version

1.2.1

License

CC0

Maintainer

David Bosak

Last Published

October 9th, 2021

Functions in libr (1.2.1)

dictionary

Create a Data Dictionary
lib_add

Add Data to a Data Library
%eq%

Check equality of two objects
dsattr

Assign Datastep Variable Attributes
lib_copy

Copy a Data Library
dsarray

Create a Data Step Array
is.lib

Class test for a data library
import_spec

Create an Import Specification
datastep

Step through data row-by-row
length.dsarray

Length function for dsarray class
lib_load

Load a Library into the Workspace
lib_replace

Replace Data in a Data Library
lib_remove

Remove Data from a Data Library
write.specs

Write import specs to the file system
lib_sync

Synchronize Loaded Library
lib_unload

Unload a Library from the Workspace
lib_size

Get the Size of a Data Library
[.dsarray

Indexer for Data Step Array
print.lib

Print a data library
lib_write

Write a Data Library to the File System
print.specs

Print import specifications
lib_path

Get the Path for a Data Library
lib_delete

Delete a Data Library
lib_info

Get Information about a Data Library
libr

Libnames, Data Dictionaries and Data Steps
libname

Create a data library
read.specs

Read import specs from the file system
specs

Create an Import Spec Collection