R Under development (unstable) (2024-01-23 r85822 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > source("incl/start.R") Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.26.0 successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object is masked from 'package:R.methodsS3': throw The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, load, save R.filesets v2.15.1 successfully loaded. See ?R.filesets for help. Attaching package: 'R.filesets' The following objects are masked from 'package:base': append, readLines > > message("*** readDataFrame()") *** readDataFrame() > > path <- system.file("exData", "dataSetA,original", package="R.filesets") > pathnames <- list.files(path=path, pattern="[.]txt$", full.names=TRUE) > pathname <- pathnames[1] > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Basic reading > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > data <- readDataFrame(pathname) > print(data) x y fac char 1 1 3 D r 2 2 2 A b 3 2 6 D g 4 1 7 B q 5 3 10 B f 6 1 2 B a 7 2 24 E g 8 1 4 E d 9 1 1 G g 10 1 2 A j > > data <- readDataFrame(basename(pathname), path=dirname(pathname)) > print(data) x y fac char 1 1 3 D r 2 2 2 A b 3 2 6 D g 4 1 7 B q 5 3 10 B f 6 1 2 B a 7 2 24 E g 8 1 4 E d 9 1 1 G g 10 1 2 A j > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Reading gzip'ed file > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > pathT <- tempdir() > pathnameZ <- file.path(pathT, sprintf("%s.gz", basename(pathname))) > R.utils::gzip(pathname, pathnameZ, remove=FALSE) > dataZ <- readDataFrame(pathnameZ) > print(dataZ) x y fac char 1 1 3 D r 2 2 2 A b 3 2 6 D g 4 1 7 B q 5 3 10 B f 6 1 2 B a 7 2 24 E g 8 1 4 E d 9 1 1 G g 10 1 2 A j > > ## Validate > stopifnot(identical(dataZ, data)) > > ## Cleanup > file.remove(pathnameZ) [1] TRUE > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Reading multiple files and stack them > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > pathnames <- rep(pathname, times=3L) > data <- readDataFrame(pathnames) > print(data) x y fac char 1 1 3 D r 2 2 2 A b 3 2 6 D g 4 1 7 B q 5 3 10 B f 6 1 2 B a 7 2 24 E g 8 1 4 E d 9 1 1 G g 10 1 2 A j 11 1 3 D r 12 2 2 A b 13 2 6 D g 14 1 7 B q 15 3 10 B f 16 1 2 B a 17 2 24 E g 18 1 4 E d 19 1 1 G g 20 1 2 A j 21 1 3 D r 22 2 2 A b 23 2 6 D g 24 1 7 B q 25 3 10 B f 26 1 2 B a 27 2 24 E g 28 1 4 E d 29 1 1 G g 30 1 2 A j > > source("incl/end.R") > > proc.time() user system elapsed 3.35 25.10 29.17