Skip to content

Commit da488bb

Browse files
committed
build
1 parent 3018f6a commit da488bb

14 files changed

Lines changed: 238 additions & 236 deletions

.Rbuildignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
^.*\.Rproj$
2-
^\.Rproj\.user$
3-
^\.github$
1+
^.*\.Rproj$
2+
^\.Rproj\.user$
3+
^\.github$

.github/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.html
1+
*.html

.github/workflows/R-CMD-check.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
on:
2-
push:
3-
branches:
4-
- master
5-
pull_request:
6-
branches:
7-
- master
8-
9-
name: R-CMD-check
10-
11-
jobs:
12-
R-CMD-check:
13-
runs-on: macOS-latest
14-
steps:
15-
- uses: actions/checkout@v2
16-
- uses: r-lib/actions/setup-r@master
17-
- name: Install dependencies
18-
run: |
19-
install.packages(c("remotes", "rcmdcheck"))
20-
remotes::install_deps(dependencies = TRUE)
21-
shell: Rscript {0}
22-
- name: Check
23-
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
24-
shell: Rscript {0}
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
9+
name: R-CMD-check
10+
11+
jobs:
12+
R-CMD-check:
13+
runs-on: macOS-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: r-lib/actions/setup-r@master
17+
- name: Install dependencies
18+
run: |
19+
install.packages(c("remotes", "rcmdcheck"))
20+
remotes::install_deps(dependencies = TRUE)
21+
shell: Rscript {0}
22+
- name: Check
23+
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
24+
shell: Rscript {0}

.gitignore

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
.Rproj.user
2-
.Rhistory
3-
.RData
4-
.Ruserdata
5-
inst/prep.R
6-
inst/literatur.bib.bak
7-
inst/literatur.bib.sav
8-
*.log
9-
*.aux
10-
*.out
11-
*.fls
12-
*.fdb*
13-
*.ttf
14-
inst/doc
1+
.Rproj.user
2+
.Rhistory
3+
.RData
4+
.Ruserdata
5+
inst/prep.R
6+
inst/literatur.bib.bak
7+
inst/literatur.bib.sav
8+
*.log
9+
*.aux
10+
*.out
11+
*.fls
12+
*.fdb*
13+
*.ttf
14+
inst/doc

DESCRIPTION

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
Package: datplot
2-
Type: Package
3-
Title: Preparation of object dating ranges for density plots
4-
Version: 0.2.1
5-
Author: Lisa Steinmann
6-
Maintainer: Lisa Steinmann <lisa.steinmann@rub.de>
7-
Description: Converting date ranges into dating 'steps' eases the visualization of changes in e.g. pottery consumption, style and other variables over time. This package provides tools to process and prepare data for visualization.
8-
License: CC BY-SA 4.0
9-
Encoding: UTF-8
10-
LazyData: true
11-
RoxygenNote: 7.1.0
12-
Suggests:
13-
testthat,
14-
devtools,
15-
knitr,
16-
rmarkdown
17-
Depends:
18-
R (>= 2.10)
19-
VignetteBuilder: knitr
1+
Package: datplot
2+
Type: Package
3+
Title: Preparation of object dating ranges for density plots
4+
Version: 0.2.1
5+
Author: Lisa Steinmann
6+
Maintainer: Lisa Steinmann <lisa.steinmann@rub.de>
7+
Description: Converting date ranges into dating 'steps' eases the visualization of changes in e.g. pottery consumption, style and other variables over time. This package provides tools to process and prepare data for visualization.
8+
License: CC BY-SA 4.0
9+
Encoding: UTF-8
10+
LazyData: true
11+
RoxygenNote: 7.1.0
12+
Suggests:
13+
testthat,
14+
devtools,
15+
knitr,
16+
rmarkdown
17+
Depends:
18+
R (>= 2.10)
19+
VignetteBuilder: knitr

R/data.R

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
#' datplot Testing data
2-
#'
3-
#' A test dataset containing a data.frame how it should ideally be arranged to work with datplot.
4-
#' Data are not real and illustrate some common problems such as lower and upper dating in the wrong columns.
5-
#'
6-
#' \itemize{
7-
#' \item ID. Identifier of the Objects (has to be unique)
8-
#' \item var. Grouping variable, such as a Type or a Findspot
9-
#' \item DAT_min. Integer: lower range of the dating, BCE in negative numbers
10-
#' \item DAT_max. Integer: uppder range of the dating, BCE in negative numbers
11-
#' }
12-
#'
13-
#' @docType data
14-
#' @keywords datasets
15-
#' @name DAT_df
16-
#' @usage data(DAT_df)
17-
#' @format A data frame with 5000 rows and 4 variables
18-
19-
"DAT_df"
20-
NULL
21-
22-
23-
#' Beazley (sample of 1000)
24-
#'
25-
#' A test dataset containing a data.frame how it should ideally be arranged to work with datplot.
26-
#' Data are gathered from the Beazley Archive Pottery Database (BAPD) -- https://www.beazley.ox.ac.uk/pottery/default.htm
27-
#' and transformed to work with datplot
28-
#'
29-
#' \itemize{
30-
#' \item Identifier (Vase.Number in BAPD)
31-
#' \item Technique: Sample contains only red- or blackfigured objects
32-
#' \item DAT_min. Integer: lower range of the dating, BCE in negative numbers
33-
#' \item DAT_max. Integer: uppder range of the dating, BCE in negative numbers
34-
#' }
35-
#'
36-
#' @docType data
37-
#' @keywords datasets
38-
#' @name Beazley
39-
#' @usage data(Beazley)
40-
#' @format A data frame with 1000 rows and 4 variables
41-
#' @source https://www.beazley.ox.ac.uk/pottery/default.htm
42-
43-
"Beazley"
44-
NULL
1+
#' datplot Testing data
2+
#'
3+
#' A test dataset containing a data.frame how it should ideally be arranged to work with datplot.
4+
#' Data are not real and illustrate some common problems such as lower and upper dating in the wrong columns.
5+
#'
6+
#' \itemize{
7+
#' \item ID. Identifier of the Objects (has to be unique)
8+
#' \item var. Grouping variable, such as a Type or a Findspot
9+
#' \item DAT_min. Integer: lower range of the dating, BCE in negative numbers
10+
#' \item DAT_max. Integer: uppder range of the dating, BCE in negative numbers
11+
#' }
12+
#'
13+
#' @docType data
14+
#' @keywords datasets
15+
#' @name DAT_df
16+
#' @usage data(DAT_df)
17+
#' @format A data frame with 5000 rows and 4 variables
18+
19+
"DAT_df"
20+
NULL
21+
22+
23+
#' Beazley (sample of 1000)
24+
#'
25+
#' A test dataset containing a data.frame how it should ideally be arranged to work with datplot.
26+
#' Data are gathered from the Beazley Archive Pottery Database (BAPD) -- https://www.beazley.ox.ac.uk/pottery/default.htm
27+
#' and transformed to work with datplot
28+
#'
29+
#' \itemize{
30+
#' \item Identifier (Vase.Number in BAPD)
31+
#' \item Technique: Sample contains only red- or blackfigured objects
32+
#' \item DAT_min. Integer: lower range of the dating, BCE in negative numbers
33+
#' \item DAT_max. Integer: uppder range of the dating, BCE in negative numbers
34+
#' }
35+
#'
36+
#' @docType data
37+
#' @keywords datasets
38+
#' @name Beazley
39+
#' @usage data(Beazley)
40+
#' @format A data frame with 1000 rows and 4 variables
41+
#' @source https://www.beazley.ox.ac.uk/pottery/default.htm
42+
43+
"Beazley"
44+
NULL

R/datsteps.R

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
#' @title Create 'steps' of dates for each object in a dataframe
2-
#'
3-
#' @description Requires a dataframe with 4 variables: ID (ideally factor), group (ideally factor),
4-
#' minimum date (int/numeric) and maximum date (int/numeric). It's expected that dates BCE are
5-
#' displayed as negative values while dates CE are positive values. Ignoring this will cause problems
6-
#' in any case.
7-
#'
8-
#' @param DAT_df a dataframe with 4 variables: ID, group, minimum date (int/num) maximum date (int/num), _must_ be in this order, colnames are irrelevant; each object _must_ be one row.
9-
#' @param stepsize defaults to 5. Number of years that should be used as an interval for creating dating steps.
10-
#'
11-
#' @return a larger dataframe with a number of steps for each object as well as a 'weight' value, that is a quantification of how well the object is dated (lesser value means object is dated to larger timespans, i.e. with less confidence)
12-
#'
13-
#' @examples
14-
#' DAT_df_steps <- datsteps(DAT_df[1:100,], stepsize = 25)
15-
#' plot(density(DAT_df_steps$DAT_step))
16-
#'
17-
#'
18-
#' @export datsteps
19-
20-
datsteps <- function(DAT_df, stepsize = 25) {
21-
if (any(DAT_df[,3] > DAT_df[,4])) {
22-
warning(paste("Warning: Dating seems to be in wrong order at ID ", paste(DAT_df[which(DAT_df[,3] > DAT_df[,4]),1], collapse = ", "), " (Index: ",
23-
paste(which(DAT_df[,3] > DAT_df[,4]), collapse = ", "), ")",
24-
". Dates have been switched, but be sure to check your original data for possible mistakes.", sep = ""))
25-
DAT_err <- which(DAT_df[,3] > DAT_df[,4])
26-
DAT_df <- switch.dating(DAT_df, DAT_err)
27-
}
28-
29-
DAT_mat <- matrix(ncol = 5, nrow = nrow(DAT_df))
30-
DAT_mat[,1] <- 1:nrow(DAT_df)
31-
DAT_mat[,2] <- DAT_df[,3]
32-
DAT_mat[,3] <- DAT_df[,4]
33-
34-
colnames(DAT_mat) <- c("index", "datmin", "datmax", "weight", "step")
35-
36-
if (stepsize == "auto") {
37-
stepsize <- generate.stepsize(DAT_mat)
38-
} else if (!is.numeric(stepsize)) {
39-
stop(print("stepsize has to be either 'auto' or numeric."))
40-
}
41-
42-
weights <- get.weights(DAT_mat[,"datmin"], DAT_mat[,"datmax"])
43-
44-
DAT_mat[,"weight"] <- weights[,1]
45-
DAT_res <- create.sub.objects(DAT_mat, stepsize)
46-
47-
48-
result <- as.data.frame(DAT_res)
49-
50-
51-
result[,2] <- DAT_df[result[,1],2]
52-
result[,1] <- DAT_df[result[,1],1]
53-
54-
colnames(result) <- c("ID", "variable", "DAT_min", "DAT_max", "weight", "DAT_step")
55-
attr(result$DAT_step, "descr") <- "step"
56-
attr(result$weight, "descr") <- "weight"
57-
58-
return(result)
59-
}
1+
#' @title Create 'steps' of dates for each object in a dataframe
2+
#'
3+
#' @description Requires a dataframe with 4 variables: ID (ideally factor), group (ideally factor),
4+
#' minimum date (int/numeric) and maximum date (int/numeric). It's expected that dates BCE are
5+
#' displayed as negative values while dates CE are positive values. Ignoring this will cause problems
6+
#' in any case.
7+
#'
8+
#' @param DAT_df a dataframe with 4 variables: ID, group, minimum date (int/num) maximum date (int/num), _must_ be in this order, colnames are irrelevant; each object _must_ be one row.
9+
#' @param stepsize defaults to 5. Number of years that should be used as an interval for creating dating steps.
10+
#'
11+
#' @return a larger dataframe with a number of steps for each object as well as a 'weight' value, that is a quantification of how well the object is dated (lesser value means object is dated to larger timespans, i.e. with less confidence)
12+
#'
13+
#' @examples
14+
#' DAT_df_steps <- datsteps(DAT_df[1:100,], stepsize = 25)
15+
#' plot(density(DAT_df_steps$DAT_step))
16+
#'
17+
#'
18+
#' @export datsteps
19+
20+
datsteps <- function(DAT_df, stepsize = 25) {
21+
if (any(DAT_df[,3] > DAT_df[,4])) {
22+
warning(paste("Warning: Dating seems to be in wrong order at ID ", paste(DAT_df[which(DAT_df[,3] > DAT_df[,4]),1], collapse = ", "), " (Index: ",
23+
paste(which(DAT_df[,3] > DAT_df[,4]), collapse = ", "), ")",
24+
". Dates have been switched, but be sure to check your original data for possible mistakes.", sep = ""))
25+
DAT_err <- which(DAT_df[,3] > DAT_df[,4])
26+
DAT_df <- switch.dating(DAT_df, DAT_err)
27+
}
28+
29+
DAT_mat <- matrix(ncol = 5, nrow = nrow(DAT_df))
30+
DAT_mat[,1] <- 1:nrow(DAT_df)
31+
DAT_mat[,2] <- DAT_df[,3]
32+
DAT_mat[,3] <- DAT_df[,4]
33+
34+
colnames(DAT_mat) <- c("index", "datmin", "datmax", "weight", "step")
35+
36+
if (stepsize == "auto") {
37+
stepsize <- generate.stepsize(DAT_mat)
38+
} else if (!is.numeric(stepsize)) {
39+
stop(print("stepsize has to be either 'auto' or numeric."))
40+
}
41+
42+
weights <- get.weights(DAT_mat[,"datmin"], DAT_mat[,"datmax"])
43+
44+
DAT_mat[,"weight"] <- weights[,1]
45+
DAT_res <- create.sub.objects(DAT_mat, stepsize)
46+
47+
48+
result <- as.data.frame(DAT_res)
49+
50+
51+
result[,2] <- DAT_df[result[,1],2]
52+
result[,1] <- DAT_df[result[,1],1]
53+
54+
colnames(result) <- c("ID", "variable", "DAT_min", "DAT_max", "weight", "DAT_step")
55+
attr(result$DAT_step, "descr") <- "step"
56+
attr(result$weight, "descr") <- "weight"
57+
58+
return(result)
59+
}

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
<!-- README.md is generated from README.Rmd. Please edit that file -->
2-
<!-- badges: start -->
3-
[![R build status](https://github.com/lsteinmann/datplot/workflows/R-CMD-check/badge.svg)](https://github.com/lsteinmann/datplot/actions)
4-
<!-- badges: end -->
5-
6-
datplot
7-
=======
8-
9-
Converting date ranges into dating 'steps' eases the visualization of changes in e.g. pottery consumption, style and other variables over time. This package provides tools to process and prepare data for visualization.
10-
11-
A rather common problem in archaeology is the fuzzyness of dates assigned to objects. If one wants to visualize overall changes in - let's say - pottery consumption, bar charts often fall short in that regard. Let's say we have Phases a -- f, then some of the objects can usually be dated to a, c, and f, as an example, but others will by classified as "a to c" or "b to c". But how can these data still be used for examining changes in a large set of objects without completely disregarding them?
12-
13-
I would propose using density plots as I did in the Demo (vignettes). They are easy to understand and are usually asthetically pleasing. Obviously they do omit a some information, such as individual counts, that bar charts display a lot better. On the other hand, ranges can be incorporated into the visualization as well, which is a lot more difficult using bar charts.
14-
15-
I imagine this to be mostly usefull for surveys and other analysis aimed at the longue duree.
16-
17-
![Attic Pottery from BAPD by Date](vignettes/demo_image.png "Attic Pottery from BAPD by Date")
18-
19-
Contact
20-
-------
21-
22-
Please feel free to use this idea or the package in your research. I would be happy if you contacted me if you do, because I'm interested whether this helps anybody. Also, if you have other ideas, critique or improvements, I would be very glad to hear from you.
23-
24-
[![Licence](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
1+
<!-- README.md is generated from README.Rmd. Please edit that file -->
2+
<!-- badges: start -->
3+
[![R build status](https://github.com/lsteinmann/datplot/workflows/R-CMD-check/badge.svg)](https://github.com/lsteinmann/datplot/actions)
4+
<!-- badges: end -->
5+
6+
datplot
7+
=======
8+
9+
Converting date ranges into dating 'steps' eases the visualization of changes in e.g. pottery consumption, style and other variables over time. This package provides tools to process and prepare data for visualization.
10+
11+
A rather common problem in archaeology is the fuzzyness of dates assigned to objects. If one wants to visualize overall changes in - let's say - pottery consumption, bar charts often fall short in that regard. Let's say we have Phases a -- f, then some of the objects can usually be dated to a, c, and f, as an example, but others will by classified as "a to c" or "b to c". But how can these data still be used for examining changes in a large set of objects without completely disregarding them?
12+
13+
I would propose using density plots as I did in the Demo (vignettes). They are easy to understand and are usually asthetically pleasing. Obviously they do omit a some information, such as individual counts, that bar charts display a lot better. On the other hand, ranges can be incorporated into the visualization as well, which is a lot more difficult using bar charts.
14+
15+
I imagine this to be mostly usefull for surveys and other analysis aimed at the longue duree.
16+
17+
![Attic Pottery from BAPD by Date](vignettes/demo_image.png "Attic Pottery from BAPD by Date")
18+
19+
Contact
20+
-------
21+
22+
Please feel free to use this idea or the package in your research. I would be happy if you contacted me if you do, because I'm interested whether this helps anybody. Also, if you have other ideas, critique or improvements, I would be very glad to hear from you.
23+
24+
[![Licence](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)

0 commit comments

Comments
 (0)