View source: R/lifetable_data.R
| lifeTable_read | R Documentation |
Reads a raw csv file containing the individual daily records of an
age-stage, two-sex life table experiment and
returns a life_table object, the central data structure that all
other functions of the package work with.
lifeTable_read(path, check = TRUE)
path |
Character string; path to the csv file. |
check |
Logical; if |
The csv file contains one row per individual. If the sex
column is located at column n, the layout must be:
column 1: individual ID (header ID),
columns 2 to n - 2: number of days spent in each
developmental stage (egg, larva, ..., pupa),
column n - 1: adult survival days,
column n: sex, coded F (female), M (male)
or N (died before the adult stage),
columns n + 1 onward: daily oviposition of the females
(one column per day; cells after the death of a female stay empty).
The first line of the file must contain the stage names as column
headers, including the ID column (ID) and the sex column
(gender). The sex column is located automatically by scanning the
first data row for the markers F/M/N. The file
encoding is detected automatically, so UTF-8 and GBK files are both
supported.
A life_table object; a named list with components
data |
data frame with the raw csv content |
file_name |
file name without extension |
n |
column index of the sex column |
n_1 |
|
n_2 |
|
header |
the first row of the file (stage names), as character |
encoding |
the detected file encoding |
path |
the full path of the csv file |
Chi, H. and Liu, H. (1985) Two new methods for study of insect population ecology. Bull. Inst. Zool. Acad. Sin 24(2), 225-240.
Chi, H. (1988) Life-table analysis incorporating both sexes and variable development rates among individuals. Environmental Entomology 17(1), 26-34.
lifeTable_check for data validation,
lifeTable_calculate for the complete analysis workflow.
f <- system.file("extdata", "lifetable_example.csv", package = "insectecol")
lt <- lifeTable_read(f)
head(lt$data[, 1:5])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.