Description Usage Arguments Examples
TODO
1 | load.trials(filename, header.pattern = "^(Try|Trial).*", ...)
|
filename |
|
header.pattern |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (filename, header.pattern = "^(Try|Trial).*", ...)
{
args = list(...)
stream = file(filename)
open(stream)
line = readLines(stream, n = 1, warn = FALSE, ok = TRUE)
while (length(line) > 0 && !grepl(header.pattern, line)) {
line = readLines(stream, n = 1, warn = FALSE, ok = TRUE)
}
if (length(line) == 0) {
stop(paste("Could not find header pattern '", header.pattern,
"' in file '", filename, "'.", sep = ""))
}
columns = unlist(strsplit(line, if (length(args$sep) == 0 ||
args$sep == "")
"[[:space:]]"
else args$sep))
data = tryCatch({
read.table(stream, ...)
}, error = function(e) {
d = data.frame(t(1:length(columns)))[0, ]
})
close(stream)
colnames(data) = columns
data
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.