Learn R Programming

Momocs (version 1.4.1)

lf_structure: bind_db.Coe <- bind_db.Coo Extracts structure from filenames

Description

If filenames are consistently named with the same character serating factors, and with every individual including its belonging levels, e.g.:

  • 001_speciesI_siteA_ind1_dorsalview

  • 002_speciesI_siteA_ind2_lateralview

etc., this function returns a data.frame from it that can be passed to Out, Opn, Ldk objects.

Usage

lf_structure(lf, names = character(), split = "_", trim.extension = FALSE)

Value

data.frame with, for every individual, the corresponding level for every group.

Arguments

lf

a list (its names are used, except if it is a list from import_tps in this case names(lf$coo) is used) of a list of filenames, as characters, typically such as those obtained with list.files. Alternatively, a path to a folder containing the files. Actually, if lf is of length 1 (a single character), the function assumes it is a path and do a list.files on it.

names

the names of the groups, as a vector of characters which length corresponds to the number of groups.

split

character, the spliting factor used for the file names.

trim.extension

logical. Whether to remove the last for characters in filenames, typically their extension, e.g. '.jpg'.

Details

The number of groups must be consistent across filenames.

See Also

import_jpg1, import_Conte, import_txt, lf_structure. See also Momocs' vignettes for data import.

Other babel functions: tie_jpg_txt()