readExperimentDir: Read data from an experiment-like files in a directory

Description Usage Arguments Details Value See Also Examples

View source: R/loading_functions.R

Description

This function reads the data from all the files in a directory. Only one column of results is expected in each file. If the files contain the results of two or more algorithms, see function readComparisonFile. The function can extract information from the file name.

Usage

1
2
readExperimentDir(directory, names, fname.pattern, alg.var.name, value.col,
  col.names = NULL, ...)

Arguments

directory

Directory with the files to load. It should only contain files to load, no other kind of file.

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, to store the whole file name the expression '([.]*)' can be used. For more example see the examples below or the vignette covering the data loading.

alg.var.name

Name of the variable that defines the algorithm used in the experiment. It can be either one of the variables extracted from the file name or the name of one of the columns in the file.

value.col

Name or index (referred to the column in the file) of the column containing the results.

col.names

Vector of names for the columns. If not provided (or NULL) the names will be read from the first line of the file.

...

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.

Details

Note that all the files should have the same format (same number of columns and, in case they have, same header)

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, readComparisonFile, 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
13
dir <- paste(system.file("loading_tests",package="scmamp"), "experiment_files", sep="/")
# The format of the files is rgg_size_SIZE_r_RADIUS_ALGORITHM.out, where variables 
# to extract are in capital letters. 
list.files(dir)[1:5]
# 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]*)_([a-z,A-Z,1,2]*).out"
var.names <- c("Size", "Radius", "Algorithm")
data <- readExperimentDir (directory=dir, names=var.names, fname.pattern=pattern, 
                           alg.var.name="Algorithm", value.col="Evaluation", 
                           col.names="Evaluation")
dim(data)
head(data)

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