readFolder: Read folder

Description Usage Arguments Examples

View source: R/readFolder_function.R

Description

This function reads all files in a folder.

Usage

1
2
readFolder(dir, pattern = "*", format = "data.frame", addFileName = NULL,
  fun, ...)

Arguments

dir

directory to folder.

pattern

wildcard pattern for filenames. Defaults to "*".

format

the format to be returned. Either a list or data.frame. Defaults to data.frame.

addFileName

column name if filename should be added to data.frame. Defaults to NULL.

fun

function to be applied to each file in the folder.

...

optional arguments passed to read.table. See ?read.table

Examples

1
2
3
4
5
6
7
Calculate the cumulative value for a variable("score") in a new variable("cumscore")
cumulativeSum = function(data) {
   data[, "cumscore"] = cumsum(data[, "score"])
   return(data)
}
dir = "c:/experiments/experiment1/"
data = readFolder(dir, fun = cumulativeSum)

espenmei/readFolder documentation built on May 13, 2017, 8:24 p.m.