read_out_ID: Read out participant IDs of a specified format from filenames

Description Usage Arguments Details Author(s) Examples

View source: R/read_out_ID.R

Description

Read out participant IDs of a specified format from filenames

Usage

1
2
read_out_ID(ID_format, folderpath = ".", filenames = FALSE,
  remove_ = TRUE, ...)

Arguments

ID_format

The way the participant ID is structured. See details.

folderpath

A (vector of) character string(s) of the folder path(s) you want to extract participant IDs from. If none is provided, the current working directory is searched. You can also just pass a (vector of) file name(s).

filenames

Do you want to get the filenames that contain valid IDs rather than just the IDs? Defaults to FALSE.

remove_

When the ID is separated from the actual file name with an underscore (i.e. if ID_format ends with an underscore), it gets removed in the output. If you want to keep an underscore at the end of each participant's ID, you can prevent this behaviour by setting remode_ to FALSE. Defaults to TRUE.

...

Additional arguments for list.files(), if folderpath contains (a) folder path(s).

Details

When you have consistent file names that start with a participant ID (or a number followed by an underscore and a participant ID), read_out_ID() will extract it for you. It will either take into account all files in a given folder (path passed in folderpath) or a (vector of) single file name(s).

You need to specify the format the IDs have via ID_format. That is, you give an example where "X" is a letter and "0" is a digit. And _ is an underscore. For example, when your participant IDs look like "JD_29MM" or "JT_03KD", you'd type in "XX_00XX". X can stand for an upper or lower case letter.

Because you can directly run them from your console, the examples in this documentation only work with file names. However, if you'd like to see examples with a folder (path), head to the example folder on GitHub.

Author(s)

Juliane Tkotz juliane.tkotz@hhu.de

Examples

1
2
3
4
5
6
my_files <- c("LF00AP_data.txt", "JT13MP_data.txt", "MT99KD_data.txt",
              "dont_catch_me.txt")
read_out_ID("XX00XX_", my_files)

read_out_ID("XX00XX_", my_files, remove_ = FALSE)
read_out_ID("XX00XX_", my_files, filenames = TRUE)

einGlasRotwein/ForBioPsy documentation built on Nov. 4, 2019, 11:49 a.m.