Giter Site home page Giter Site logo

joeroe / stratigraphr Goto Github PK

View Code? Open in Web Editor NEW
20.0 6.0 1.0 2 MB

R package for archaeological stratigraphy and chronological sequences

Home Page: https://stratigraphr.joeroe.io

License: Other

R 95.21% TeX 4.79%
r r-package archaeology stratigraphy radiocarbon-dates tidyverse

stratigraphr's Introduction

stratigraphr

Lifecycle: experimental CRAN status R build status Codecov test coverage

stratigraphr is a tidy framework for working with archaeological stratigraphy and chronology in R. It includes tools for reading, analysing, and visualising stratigraphies (Harris matrices) and sequences as directed graphs; helper functions for using radiocarbon dates in a tidy data analysis; and an R interface to OxCal's Chronological Query Language (CQL).

Installation

You can install the development version of stratigraphr from GitHub:

# install.packages("devtools")
devtools::install_github("joeroe/stratigraphr")

Please note that this package is in an early stage of development. It is functional, but many features are missing and future versions are likely to contain breaking changes.

Usage

  • Graph-bases stratigraphic analysis: see vignette("stratigraph").
  • Tidy analysis of radiocarbon dates: see vignette("tidy_radiocarbon").
  • Chronological query language: see vignette("cql").

stratigraphr's People

Contributors

joeroe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nevrome

stratigraphr's Issues

Trim dependencies

Do we really need?

Imports:

Suggests:

  • bchron, no, remove with #14
  • covr, yes
  • fs, no
  • ggplot2, maybe not after #14
  • ggraph, yes
  • knitr, yes
  • oxcaar, yes
  • readxl, surely not?
  • rmarkdown, yes
  • testthat, yes

Support constructing stratigraphs from tidy data frames

I.e.,

data.frame(
    unit = c("A", "B", "C", "C"),
    above = c(NA, "A", "A", "B")
)

Should have the same result as

tibble(
    unit = c("A", "B", "C"),
    above = list(NA, "A", c("A", "B"))
)

does now.

Don't know how common this format will be in the wild, but it's much easier for quickly constructing graphs in R itself.

Should be configurable, but also probably the default if label is not unique?

strat_is_valid() should detect the source of a cycle

igraph has a feedback_arc_set function that can help isolate the source of a cycle. IIRC, the package implements a fast approximate algorithm (which is helpful) and a slower exact algorithm (which is what most users will probably enjoy).

Input and output formats

We should be able to read and write data to/from these formats:

We probably won't be handle these formats:

read_lst() doesn't work with Stratify files

Using harris2graph's example Stratify .lst file:

library(stratigraphr)
tmpfile <- fs::file_temp()
download.file("https://raw.githubusercontent.com/lparchaeology/harris2graph/master/stratify.lst", tmpfile)
#> trying URL 'https://raw.githubusercontent.com/lparchaeology/harris2graph/master/stratify.lst'
#> Content type 'text/plain; charset=utf-8' length 1537 bytes
#> ==================================================
#> downloaded 1537 bytes
#> 
read_lst(tmpfile)
#> New names:
#> * below -> below...1
#> * below -> below...4
#> New names:
#> * Unit_class -> Unit_class...1
#> * Unit_class -> Unit_class...4
#> New names:
#> * TST -> TST...1
#> * TST -> TST...4
#> New names:
#> * Unit_class -> Unit_class...1
#> * Unit_class -> Unit_class...4
#> New names:
#> * below -> below...1
#> * below -> below...4
#> Error in if (value == "") { : missing value where TRUE/FALSE needed

This is because, predictably, Stratify doesn't follow the assumption that LST files always use 5 lines per stratum. We will need a more flexible way of initially splitting the file by stratum in read_lst().

Unimplemented CQL commands

  • cql_age()
  • cql_axis()
  • cql_c_combine()
  • cql_c_simulate()
  • cql_correl_matrix()
  • cql_correlation()
  • cql_covar_matrix()
  • cql_curve()
  • cql_delta_r()
  • cql_difference()
  • cql_end()
  • cql_exp()
  • cql_gap()
  • cql_interval()
  • cql_kde_model()
  • cql_kde_plot()
  • cql_label()
  • cql_line()
  • cql_mcmc_sample()
  • cql_mix_curves()
  • cql_number()
  • cql_offset()
  • cql_outlier()
  • cql_outlier_model()
  • cql_p()
  • cql_pois()
  • cql_prior()
  • cql_probability()
  • cql_r_combine()
  • cql_r_simulate()
  • cql_reservoir()
  • cql_sample()
  • cql_sapwood()
  • cql_sapwood_model()
  • cql_shift()
  • cql_start()
  • cql_after()
  • cql_before()
  • cql_combine()
  • cql_first()
  • cql_last()
  • cql_order()
  • cql_span()
  • cql_sum()

Validate stratigraphs

I don't know the R graph packages well, but you'll want to use one that is able to check for cycles. I browsed ggraph and didn't see anything there, but igraph will run this check. I believe that is what @nevrome was getting at in the thread with @zachbatist when he mentioned the logic check.

Also, if you decide to push forward with this, please consider the data structures set out by Dye and Buck (2015) and used in hm. The idea there was to have hm read csv files generated by SQL queries.

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.