writeTemplates: Write Acoustic Templates to Text Files

writeTemplatesR Documentation

Write Acoustic Templates to Text Files

Description

These functions write all templates within a template list to text files within a specified directory.

Usage

writeCorTemplates(..., dir = ".", ext = "ct", parallel = FALSE)
writeBinTemplates(..., dir = ".", ext = "bt", parallel = FALSE)

Arguments

...

One or more template lists.

dir

A file path to the directory where the files should be saved. If it doesn't exist, the function will create it. By default, the working directory.

ext

The file extension used for the new file(s).

parallel

Set to TRUE to use mclapply from the parallel package to speed up the call for large template lists (not available for Windows operating systems).

Details

For correlation templates (class corTemplateList) use writeCorTemplates, and use writeBinTemplates for binary templates (class linkS4class{binTemplateList}). To write only some of the templates in a list to file, use indexing ([-methods).

Value

NULL, invisibly.

Author(s)

Sasha D. Hafner

See Also

makeCorTemplate, makeBinTemplate, readBinTemplates, readCorTemplates

Examples

# Load data
data(btnw)
data(oven)

# Write Wave objects to file (temporary directory used here)
btnw.fp <- file.path(tempdir(), "btnw.wav")
oven.fp <- file.path(tempdir(), "oven.wav")
writeWave(btnw, btnw.fp)
writeWave(oven, oven.fp)

# Create four correlation templates
wct1 <- makeCorTemplate(btnw.fp, name = "w1")
wct2 <- makeCorTemplate(btnw.fp, t.lim = c(1.5, 2.1), frq.lim = c(4.2, 5.6), name = "w2")
oct1 <- makeCorTemplate(oven.fp, t.lim = c(1, 4), frq.lim = c(1, 11), name = "o1")
oct2 <- makeCorTemplate(oven.fp, t.lim = c(1, 4), frq.lim = c(1, 11), dens = 0.1, name = "o2")

# Combine all of them
ctemps <- combineCorTemplates(wct1, wct2, oct1, oct2)

# To write ctemps to a directory "templates"
## Not run: 
# Not run because it will write files outside of user's temporary directory
writeCorTemplates(ctemps, dir = "templates")

## End(Not run)

# Clean up (only because these files were created in these examples)
file.remove(btnw.fp)
file.remove(oven.fp)

jonkatz2/monitoR documentation built on March 27, 2024, 4:39 p.m.