Learn R Programming

cdb (version 0.0.1)

read.cdb: Reads a cdb file

Description

This function reads a cdb file (or its text version) and creates a data frame with the keys and values.

Usage

read.cdb(file, type=c("cdb","txt"))

Arguments

file
The name of the cdb file to read.
type
A character string describing the type of file. Value cdb reads a file with the native format; txt needs a text record format. See the Details section.

Value

An object of the class data.frame with two columns: The first one collects the keys and the second one shows the values.

Details

This function reads data files in the cdb format or in its text version. The format is described in the documents of the reference section.

It reads all the keys and values and transforms them as a data frame with two columns.

References

D. J. Bernstein The cdbmake and cdbdump programs http://cr.yp.to/cdb/cdbmake.html

Yusuke Shinyama (2003) Constant Database (cdb) Internals http://www.unixuser.org/~euske/doc/cdbinternals/ Michael Tokarev (2012) TinyCDB - a Constant DataBase http://www.corpit.ru/mjt/tinycdb.html

See Also

write.cdb

Examples

Run this code
packages <- rownames(as.data.frame(installed.packages()))
set.seed(123)
a <- data.frame(key=sample(packages, 10, replace = TRUE),
                value=sample(packages, 10, replace = TRUE))
write.cdb(a, "Base.txt", type="txt")

b <- read.cdb("Base.txt", type="txt")
b

c <- read.cdb(system.file("extdata", "example.cdb",
                        package = "cdb"))
c

Run the code above in your browser using DataLab