Skip to contents

Determines which epoch(s) one or more years belong to.

Usage

get_epoch(year, epochs, label = TRUE)

Arguments

year

Numeric vector of years to classify.

epochs

An object of class "milestone_epochs" created by define_epochs.

label

Logical. If TRUE, return epoch labels; if FALSE, return epoch IDs.

Value

A character vector (if label = TRUE) or integer vector (if label = FALSE) indicating which epoch each year belongs to. Years outside the epoch range return NA.

Examples

epochs <- define_epochs()

# Which epoch is 1850?
get_epoch(1850, epochs)
#> [1] "Golden Age"

# Multiple years
get_epoch(c(1650, 1850, 1975), epochs)
#> [1] "Measurement & theory" "Golden Age"           NA                    

# Get IDs instead of labels
get_epoch(c(1650, 1850), epochs, label = FALSE)
#> [1] 2 5

# Attach epochs to all milestones for analysis
ms <- milestone()
extended <- define_epochs(extend = "before")
ms$epoch <- get_epoch(ms$date_from_numeric, extended)

# Frequency table of milestones by epoch
table(ms$epoch)
#> 
#>              Dark age Early maps & diagrams            Golden Age 
#>                    43                    11                    59 
#>            Hi-Dim Vis  Measurement & theory            Modern age 
#>                    33                    27                    39 
#>     New graphic forms            Prehistory              Re-birth 
#>                    34                    17                    22 

# Cross-tabulate by epoch and subject
ms_subjects <- milestone2subject()
ms_with_subject <- merge(ms, ms_subjects, by = "mid")
table(ms_with_subject$epoch, ms_with_subject$subject)
#>                        
#>                         Human Mathematical Other Physical
#>   Dark age                 10           25     3        5
#>   Early maps & diagrams     0            5     1        5
#>   Golden Age               22           12     8       17
#>   Hi-Dim Vis                1           31     1        0
#>   Measurement & theory      0           11     3       13
#>   Modern age               14            6     4       15
#>   New graphic forms         6           10     5       13
#>   Prehistory                2            3     4        8
#>   Re-birth                  2           19     0        1