The Rparadox package provides tools to read data from Paradox
database files (.db
) directly into R. This vignette will
walk you through the basic usage of the package.
You can install the development version from GitHub:
The main workflow involves opening a file, reading the data, and then closing the file.
library(Rparadox)
# Get the path to an example database included with the package
db_path <- system.file("extdata", "biolife.db", package = "Rparadox")
# Open the file handle
pxdoc <- pxlib_open_file(db_path)
# Read data and close the handle
if (!is.null(pxdoc)) {
biolife_data <- pxlib_get_data(pxdoc)
pxlib_close_file(pxdoc)
}
# Display the first few rows of the resulting tibble
head(biolife_data)
#> # A tibble: 6 × 8
#> `Species No` Category Common_Name `Species Name` `Length (cm)` Length_In Notes
#> <dbl> <chr> <chr> <chr> <dbl> <dbl> <chr>
#> 1 90020 Trigger… Clown Trig… Ballistoides … 50 19.7 "Als…
#> 2 90030 Snapper Red Emperor Lutjanus sebae 60 23.6 "Cal…
#> 3 90050 Wrasse Giant Maor… Cheilinus und… 229 90.2 "Thi…
#> 4 90070 Angelfi… Blue Angel… Pomacanthus n… 30 11.8 "Hab…
#> 5 90080 Cod Lunartail … Variola louti 80 31.5 "Als…
#> 6 90090 Scorpio… Firefish Pterois volit… 38 15.0 "Als…
#> # ℹ 1 more variable: Graphic <blob>
For legacy files with incorrect encoding information in the header, you can specify the correct encoding manually.
# Example for a file known to be in the CP866 encoding
pxdoc <- pxlib_open_file("path/to/your/file.db", encoding = "cp866")
This ensures that text is correctly converted to UTF-8.