Giter Site home page Giter Site logo

era's Introduction

πŸ‘‹ Hi, I'm Joe.

I'm a computational archaeologist and research software engineer at the University of Bern.

I use GitHub for software packages, research compendiums and various other projects. I try to work in the open as much as possible, so please be aware that many of my repositories are unpublished experiments, works-in-progress or abandonded ideas. Below you can find a curated list of my more 'mature' projects.

More info & contacts:

Software

R packages (stable)

  • era – year-based time scales
  • rpaleoclim – download paleoclimate data from PaleoClim

R packages (experimental)

  • c14 – tidy radiocarbon data
  • controller – tools for controlled vocabularies
  • fieldwalkr – spatial sampling and survey simulation
  • rintchron – interface to IntChron
  • stratigraphr – archaeological stratigraphy and chronological sequences

Other

Data

  • xronos – an open repository for chronometric data in archaeology (incl. R package, web app)
  • tavo-a27 – data from Uerpmann 1987, The Ancient Distribution of Ungulate Mammals in the Middle East (TAVO A27)
  • swapdata – Southwest Asian palaeoarchaeology data

Research compendiums

Published

Conference papers

  • dabawa23_enm, paper presented at "Digital Archaeology Bern – Ancient West Asia", Bern, 6–7 October 2023, 'Modelling the range of wild plants and crop progenitors in the Late Epipalaeolithic–Early Neolithic Levant'

Teaching materials

  • gis_in_archaeology – course website for 'GIS in Archaeology' (437571) at the University of Bern
  • smada – course website for 'Statistical Methods for Archaeological Data Analysis' (452240) at the University of Bern
  • r4r_visualisation – slides, code examples, and exercises for the visualisation module of R for Archaeologists, a winter school held at the University of Pisa.

Lists

Of handy GitHub repositories:

era's People

Contributors

joeroe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

era's Issues

S4 compatibility

The vctrs S3 vectors vignette suggests adding this lines to internal constructors for compatibility with S4:

methods::setOldClass(c("pizza_percent", "vctrs_vctr"))

But when I've tried it in new_yr I get an error:

era:::new_yr()
#> Error in assign(".S3MethodsClasses", S3table, envir = where): 
#>   cannot add bindings to a locked environment

Year zero problem

When converting between CE-based and BP-based eras, yr_transform() does not account for the absence of a year zero.

library("era")
yr_transform(yr(10000, "BP"), era("BCE"))
#> # BCE years <yr[1]>:
#> [1] 8051
#> # Era: Before Common Era (BCE): calendar years, counted backwards from 1

OxCal is good at this kind of thing.

Inconsistent warnings when combining eras with different labels/names

Arithmetic with yrs with functionally equivalent, but differently named, eras throws a warning as expected:

library("era")
yr(1, "BP") + yr(1, "cal BP")
#> Warning: `era(x)` and `era(y)` have different label or name parameters.
#> # BP years <yr[1]>:
#> [1] 2
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

But combining the same vectors doesn't:

c(yr(1, "BP"), yr(1, "cal BP"))
#> # BP years <yr[2]>:
#> [1] 1 1
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

Created on 2020-12-08 by the reprex package (v0.3.0)

The check currently in vec_arith.era_yr.era_yr() should be moved lower, to catch all instances of combination.

Add function for validating era_yrs

Which would check that:

  • The vec_data() is numeric or missing
  • The era attribute is set
  • The era is valid (see #7)

It should be used in the yr() constructor, but not new_yr(), to maintain the ability to create (invalid) empty yrs internally.

Conversion between eras with NA units

yr_transform() currently throws an error if either the source or destination era has an NA unit, following the R convention that NA == NA is NA.

It might not be necessary to be this strict, for example to allow transformations between era("bp") and era("bce"), and just warn that there is an assumption that the units are comparable.

Add vec_proxy_compare method for era

Currently yr_era(x) == yr_era(y) is used in several places but I don't trust it.

It also might be better to only selectively compare eras, e.g. consider eras with different labels equal if all the significant parameters are the same. Then they should be able to be combined, with a warning that the labels will be changed.

Release era 0.4.1

First release:

Prepare for release:

  • git pull
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted πŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Consider vec_proxy_compare method for era_yr

Currently:

library("era")
a <- yr(1:10, "BP")
b <- yr(1:10, "BP")
c <- yr(1:10, "BC")
a == b
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
a == c
#> Error: Can't combine `..1` <yr (BP)> and `..2` <yr (BC)>.
#> Reconcile eras with yr_transform() first.

The first result is correct. The second result maybe too strict and should return FALSE instead of an error.

Cast character to era_yr?

It could be possible to cast characters to era_yrs (i.e. the inverse of #11) in some circumstances. E.g. "1 BCE" could be interpreted as yr(1, "BCE"). But maybe this is too magical?

Release era 0.3.1

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • devtools::build_readme()
  • usethis::use_cran_comments()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran() *
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted πŸŽ‰
  • Delete CRAN-RELEASE
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Add more eras

  • Common Era
    • BC/AD
    • BCE/CE
    • Translations
  • Islamic/Hijra calendars
    • Arabic Lunar Hijri
    • Modern Iranian Solar Hijri
    • Jilali Solar Hijri
  • Indian/Hindu calendars
    • Shaka era
  • Modern Hebrew calendar
  • Buddhist calendars
  • Zoroastrian calendars https://zanc.org/zcal/zcal.html
    • Shenshai calendar
    • Fasli calendar
    • Kadmi calendar
  • Chinese calendars
  • Maya calendars
  • Other contemporary calendars
    • Juche calendar
  • Historic European calendars
    • Julian Common Era calendar
    • French Republican calendar
    • Era Fascista
  • Historic Jewish calendars
  • Ancient Egyptian calendars
  • Ancient Greek calendars
  • Ancient Roman calendars
    • AUC
    • Regnal eras
  • Other historic calendars

Many are dependent on #15.

General resources:

era(NA) has unexpected results

As a result of 86a6015, passing NA to era() constructs every available standard era:

library("era")
era(NA)
#> <era[24]>
#>  [1] Before Present (BP): calendar years, counted backwards from 1950                        
#>  [2] Before Present (cal BP): calendar years, counted backwards from 1950                    
#>  [3] Before Christ (BC): calendar years, counted backwards from 0                            
#>  [4] Before Common Era (BCE): calendar years, counted backwards from 0                       
#>  [5] Anno Domini (AD): calendar years, counted forwards from 0                               
#>  [6] Common Era (CE): calendar years, counted forwards from 0                                
#>  [7] kiloannum (ka): calendar (Γ—1000) years, counted backwards from 1950                     
#>  [8] megaannum (Ma): calendar (Γ—1e+06) years, counted backwards from 1950                    
#>  [9] gigaannum (Ga): calendar (Γ—1e+09) years, counted backwards from 1950                    
#> [10] thousand years ago (kya): calendar (Γ—1000) years, counted backwards from 1950           
#> [11] million years ago (mya): calendar (Γ—1e+06) years, counted backwards from 1950           
#> [12] billion years ago (bya): calendar (Γ—1e+09) years, counted backwards from 1950           
#> [13] years before 2000 (b2k): calendar years, counted backwards from 2000                    
#> [14] uncalibrated Before Present (uncal BP): radiocarbon years, counted backwards from 1950  
#> [15] Radiocarbon Years Before Present (RCYBP): radiocarbon years, counted backwards from 1950
#> [16] Before Present (uncalibrated) (bp): radiocarbon years, counted backwards from 1950      
#> [17] Before Christ (uncalibrated) (bc): radiocarbon years, counted backwards from 1950       
#> [18] Before Common Era (uncalibrated) (bce): radiocarbon years, counted backwards from 1950  
#> [19] Anno Domini (uncalibrated) (ad): radiocarbon years, counted forwards from 1950          
#> [20] Common Era (uncalibrated) (ce): radiocarbon years, counted forwards from 1950           
#> [21] Holocene Era (HE): calendar years, counted forwards from -10000                         
#> [22] Before Holocene Era (BHE): calendar years, counted backwards from -10000                
#> [23] Anno Lucis (AL): calendar years, counted forwards from -4000                            
#> [24] After the Development of Agriculture (ADA): calendar years, counted forwards from -8000

This is a neat trick but probably not expected from the user's point of view. It should either throw an error (could handled in validation – #7) or return an NA-era.

More informative error message for era("unknown era")

era("unknown era")
#> Error: Invalid era:
#> x `scale` must be positive
#> x `direction` must be -1 (backwards) or 1 (forwards)
#> Run `rlang::last_error()` to see where the error occurred.

Rather than trying and failing to construct an era with missing parameters, era() should recognise that the user has asked it for a predefined era that doesn't exist and give a more informative error.

yr() does not check whether era is an era

Because using vec_assert has a puzzling result:

vctrs::vec_assert(era::era("BP"), era:::new_era())
#> Error: `era::era("BP")` must be a vector with type <era>.
#> Instead, it has type <era>.

Test coverage

  • yr()
    • Returns class era_yr with valid input
    • Expect error for invalid era (needs validation function #7)
    • Expect error for multiple eras
  • yr get and set functions
    • yr_era() returns correct era
    • yr_era()<- and yr_set_era() set correct era
  • era()
    • Returns class era with valid input
    • Expect error for invalid input
  • eras()
    • Returns correct row for exact match
    • Returns correct row for partial match
    • eras() returns all rows from era_table
    • All eras defined in eras() are valid
  • era_parameters
    • Return correct output for all getters
  • yr_transform()
    • dst_era is correct
    • All significant transformations return correct result
    • Expect error for incomparable units
    • No errors for otherwise possible transformations
  • vctrs classes (suggestions: https://vctrs.r-lib.org/articles/s3-vector.html#testing-1)
    • expect_snapshot_output() of format.era_yr()
    • expect_snapshot_output() of format.era()
    • Method symmetry
    • Expect errors for inputs that can't be combined
  • vctrs arithmetic
  • era_year()

Add function for validating eras

eras are complicated enough that a validate_era() function is needed. This should be called in the era() constructor, but not new_era(), to maintain the ability to create (invalid) empty eras internally.

Year to date conversions

We should have a function for converting between era_yr and date/datetime classes. There should probably be plenty of warnings about the fact that it isn't precise.

Add precision argument to yr_transform()

yr_transform() is precise with epoch transformations, which is appropriate for more recent years but unnecessarily messy for distant ones:

library("era")
yr(100000000, "BCE") %>% 
  yr_transform(era("mya"))
#> # mya years <yr[1]>:
#> [1] 100.0019
#> # Era: million years ago (mya): calendar (Γ—1e+06) years, counted backwards from 1950

Created on 2020-11-12 by the reprex package (v0.3.0)

It would be nice to add an option to round the output to a desired level of precision in yr_transform().

Release era 0.4.0

Prepare for release:

  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4) (no reverse dependencies)
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted πŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Conversion between year units

Adding non-Gregorian calendars complicates the definition and conversion of eras. We need to account for:

  • The differing length of Gregorian vs. non-Gregorian years
  • Differing lengths within an era – leap days etc. (?)
  • Non-alignment of year starts, e.g. 1422 AH is either 2020 or 2021 CE, depending on where in the year we are

I haven't fully worked out how to do this. But some general principles:

  • The scope of this package is years; we should avoid having to explicitly consider dates if at all possible
  • In this context years are not dates. They are a measurement of the period of time elapsed from a particular epoch in a particular unit. They can be converted to dates, but only approximately.
  • It follows from this that 2020 CE is actually "2020 Gregorian years from Year Zero", and that converting it to a non-Gregorian year will probably result in a decimal value.
  • It's okay if conversions between eras are approximate (perhaps issue a warning about this though)
  • It's important that conversions between eras are symmetric

Paired eras

CE-based eras come in pairs, i.e. negative values of CE are BCE; negative values of BCE are CE. There is currently no concept of this in era. I can think of two ways to add it:

  1. As part of the definition of an era, e.g. add an inverse attribute that contains another era.
  2. As a function, which takes a year vector with negative values and splits it into two positive vectors with paired eras.

The underlying question is whether it makes sense to support paired eras in analytical use (in which case we'd need 1) or just for printing and plotting (then 2 would be enough).

era arguments should always accept a character label

Currently:

library("era")
yr(1, "BP")
#> # BP years <yr[1]>:
#> [1] 1
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

But:

yr_set_era(1, era("BP"))
#> # BP years <yr[1]>:
#> [1] 1
#> # Era: Before Present (BP): calendar years, counted backwards from 1950

Created on 2020-11-12 by the reprex package (v0.3.0)

This as annoying. Every function that has an era argument should also accept a character label to look up in eras().

Add ggplot2 scales extensions

They wouldn't do much, just change the default order of the sequence based on the era's direction attribute, and add abbreviated labels somewhere.

It would also be nice to support paired eras when plotting (#17).

Resources:

Document standard eras

Currently the standard eras known to the package are defined internally in era_dictionary(). These should at least be documented somewhere for the user. I can see two options:

  • Retain era_dictionary() as an internal function, and manually update the roxygen2 documentation for era().
  • Turn era_dictionary() into an exported function (eras()?) which, in addition to returning a specified era, could:
    • List all available eras if no argument is given
    • Do partial matching

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.