readComparisonDir: Read data from a directory of comparison-like files

Description Usage Arguments Value See Also Examples

Description

This function reads the data from all files in a directory. Each file is expected to to be formated as a comparison file, i.e., the file can have some columns that characterize the problem and one column per algorithm. If each row contain only the result obtained by one algorithm, use the readExperimentDir function.

Usage

1
2
readComparisonDir(directory, alg.cols, names, fname.pattern, col.names = NULL,
  ...)

Arguments

directory

Directory where the files are located.

alg.cols

A vector column names or indices inicating which columns contain the results. The rest are assumed as descriptors of the problems

names

List of names for the variables to be extracted from the file name.

fname.pattern

Regular expression to extract information from the file names. It has to be a regular expression that matches the name of the files and where the information to be extrcted has to be between brakets. As an example, if the whole file name wants to be used, the expression '([.]*)' can be used. For more example see the examples below or the vignette covering the data loading.

col.names

Vector of names of the columns. If not NULL, the files are assumed not to have a header and the columns are named using this vector.

...

Additional parameters for the read.csv function used to load the data. It can be used, for example, to set the separator (e.g., sep="\t"). Note that the header argument is automatically set according to the col.names argument.

Value

A data.frame where each column represents either a feature of the experiment or the result of running an algorithm. Algorithm columns are placed always at the end of the table.

See Also

readExperimentFile, readExperimentDir, readComparisonDir and the vignette vignette(topic="Data_loading_and_manipulation", package="scmamp")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dir <- paste(system.file("loading_tests",package="scmamp") , "comparison_files" , sep="/")
# The format of the files is rgg_size_SIZE_r_RADIUS.out, where variables to extract are in
# capital letters.  
list.files(dir)[1]
# The regular expresion can be as simple as substituting each variable name in the expression 
# above by ([XXX]*), where XXX is the list of symbols that appear in the name.
pattern <- "rgg_size_([0-9]*)_r_(0.[0-9]*).out"
var.names <- c("Size", "Radius")
data <- readComparisonDir (directory=dir, alg.cols=1:8, names=var.names, 
                           fname.pattern=pattern)
dim(data)
head(data)

scmamp documentation built on May 1, 2019, 10:10 p.m.