make_ids | R Documentation |
A utility to create randomised IDs from an experiment database/spreadsheet.
make_ids(
file,
range = c(0, 0),
format = "X.?.#",
filetype = "auto",
seed = 1,
...
)
file |
A spreadsheet file containing experimental metadata. It is important that information for individual subjects is in rows. |
range |
The range of ID numbers. The default will number from 1 to a maximum that is 20% more than the total number of subjects in the spreadsheet (this allows some additional subjects to be added at a later date if necessary). If you want to use a larger number of subjects in the future (which should be randomised together) or if the numbering should not start at 1, then this option can be used to override the default. |
format |
A string specifying the components making up the ID. See Details to learn how to customise this. The default is "X.?.#". |
filetype |
The filetype of the input spreadsheet. Microsoft Excel
( |
seed |
The seed used to randomise the IDs. There is no real reason that this should need to be changed, but you can if you want to. |
... |
Additional parameters passed to the file reader. The parameters accepted depend on the input filetype. |
This function creates a new spreadsheet file in the same format as the input
file (note the exception about .xls
below). This new file will be
named as the input file with "_IDs" appended to the name.
There is no support for writing to the obsolete .xls
format so the
modified files from .xls
input will be written as .xlsx
with a
message.
The label format is designed to allow for an experiment name (ideally a short abbreviation), a randomised number and a control character/checksum. Not all of these components are necessary (a minimum requirement is only the randomised number—but this is not recommended). For maximum compatibility (with R variable names and many spreadsheet tools for example), it is recommended that IDs begin with a letter rather than a number. The format uses 3 special characters:
?
is the randomised number.
Adjacent symbols will be collapsed, but it is possible (not particularly
recommended) to have the number appear multiple times.
@
is a
control character (letters that may be ambiguously written or confused with
digits are not used) that is useful as a control to distinguish
easily-confused ID numbers.
#
is a checksum character generated
using the Verhoeff algorithm.
Invisibly returns the randomised IDs (in the order they appear in the spreadsheet) as a character vector.
read_db
, or write_db
for additional information on the readable/writeable file formats.
require(idLabelR)
example_spreadsheet = system.file("extdata", "Example.txt", package = "idLabelR")
ids = make_ids(file = example_spreadsheet, format = "MyExpt.?.#")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.