Skip to content

Commit 3acdc97

Browse files
committed
year 0
removed year 0 in data preparation process, thanks reviewer#2,
1 parent 118d6dc commit 3acdc97

7 files changed

Lines changed: 50 additions & 21 deletions

File tree

data-raw/Inscr_Bithynia.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,17 @@ join_dating <- rbind(join_dating, num_dating[!is.na(num_dating$DAT_min),])
129129
num_dating <- num_dating[which(is.na(num_dating$DAT_min)),]
130130
unique(num_dating$Dating)[1:20]
131131

132+
join_dating$DAT_min[which(join_dating$DAT_min == 0)] <- 1
133+
join_dating$DAT_max[which(join_dating$DAT_max == 0)] <- -1
134+
135+
132136
#write.csv(num_dating, file = "num_dating.csv", fileEncoding = "UTF-8")
133137
num_dating <- read.csv(file = system.file('extdata', 'num_dating_edit.csv', package = 'datplot', mustWork = TRUE),
134138
encoding = "UTF-8",
135139
row.names = 1,
136140
colClasses = c("character", "character", "integer", "integer"))
137141

142+
138143
join_dating <- join_dating %>%
139144
mutate(DAT_min = as.integer(DAT_min),
140145
DAT_max = as.integer(DAT_max)) %>%
@@ -174,4 +179,7 @@ attr(inscriptions$DAT_max, "descr") <- "uppper border of the dating timespan"
174179

175180
Inscr_Bithynia <- inscriptions
176181

182+
#inscriptions[which(inscriptions$DAT_min == 0),c(1,2,4,5,8,9)]
183+
#inscriptions[which(inscriptions$DAT_max == 0),c(1,2,4,5,8,9)]
184+
177185
usethis::use_data(Inscr_Bithynia, overwrite = TRUE)

data/Inscr_Bithynia.rda

3 Bytes
Binary file not shown.

inst/extdata/num_dating_edit.csv

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
1,end of the 2nd c. AD,180,199
33
2,end of 1st c. BC – beg. of 1st c. AD,-20,20
44
3,end 2nd c. BC,-120,-100
5-
4,early 1st c. AD,0,20
5+
4,early 1st c. AD,1,20
66
7,after 212 AD,212,250
77
8,AD 531,531,531
88
10,5th/6th century AD,400,599
99
14,3rd/4th century AD,200,399
1010
19,2nd – 3rd c. AD,100,299
11-
20,2nd – 1st c. BC,-199,0
12-
27,1st – beg. of the 2nd c. AD,0,120
13-
28,1st – 2nd c. AD,0,199
11+
20,2nd – 1st c. BC,-199,-1
12+
27,1st – beg. of the 2nd c. AD,1,120
13+
28,1st – 2nd c. AD,1,199
1414
35,2nd century AD,100,199
1515
38,late 3rd – early 2nd c. BC,-220,-180
1616
43,5th – 6th c. AD,400,599
1717
50,3rd quarter of the 6th c. BC,-550,-525
1818
51,3rd – 2nd c. BC,-299,-100
1919
52,340/339 BC,-340,-339
2020
54,27 BC–14 AD,-27,14
21-
56,1st century AD,0,99
21+
56,1st century AD,1,99
2222
57,1st c. BC – 1st c. AD,-99,99
2323
60,middle 2nd c. AD,140,160
2424
61,end of the 3rd c. AD,280,299
@@ -33,13 +33,13 @@
3333
84,end of the 2nd - end of the 4th century AD,180,380
3434
87,2nd century BC,-199,-100
3535
88,2nd century AD ,100,199
36-
89,1st/2nd century AD,0,199
36+
89,1st/2nd century AD,1,199
3737
92,mid. 2nd c. AD,140,160
3838
93,mid. 1st c. AD,40,60
3939
94,late 2nd c. AD,180,199
4040
95,end of the 1st c. AD,80,99
4141
96,AD 123,123,123
42-
100,1st - 3rd century AD,0,299
42+
100,1st - 3rd century AD,1,299
4343
102,2nd/3rd century AD or 4th - 5th century AD ,100,499
4444
104,mid. 3rd c. AD,240,260
4545
105,late 3rd century AD,280,299
@@ -66,7 +66,7 @@
6666
168,2nd/3rd century AD ,100,299
6767
169,2nd half of the 2nd c. AD,150,199
6868
170,2nd – 3rd C. AD,100,299
69-
183,1st century BC,-99,0
69+
183,1st century BC,-99,-1
7070
200,102–114,102,114
7171
201,early 3rd century AD,200,220
7272
203,after 138 AD,138,150
@@ -95,6 +95,6 @@
9595
281,5th – 6th C AD,400,599
9696
283,4th – 6th c. AD,300,599
9797
284,3rd c. AD (after 211 AD),211,299
98-
285,1st – early 2nd c. AD,0,120
98+
285,1st – early 2nd c. AD,1,120
9999
288,123–131/132 AD,123,132
100100
289,AD 140,140,140

inst/extdata/periods_edit.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
11,Hellenistic period,-336,-74
1313
12,Early Roman period,-74,-31
1414
13,Chr.–Byz.,100,799
15-
14,AD,0,799
15+
14,AD,1,799
1616
15,Christian,300,799
1717
16,Antonine or Severan,96,235
1818
17,Roman period,-74,395

inst/extdata/periods_edit_AD.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
,Dating,DAT_min,DAT_max
2-
1,Roman Imp. period,0,395
3-
6,Early/Middle Roman Imp. p.,0,192
4-
7,Early Roman Imp. period,0,69
5-
10,Roman Imperial period,0,395
6-
26,Roman Imp. period ,0,395
2+
1,Roman Imp. period,1,395
3+
6,Early/Middle Roman Imp. p.,1,192
4+
7,Early Roman Imp. period,1,69
5+
10,Roman Imperial period,1,395
6+
26,Roman Imp. period ,1,395

vignettes/data_preparation.Rmd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ unique(num_dating$Dating)[1:20]
283283

284284
Due to the heterogeneous nature of these `r nrow(num_dating)` values, we decided to convert them manually again. Our criteria for translating terms like "beginning of" are the following: "beginning of", "end of", "early", "late" all translate to 20 years, as we assume that more information would have been given if the time span was greater than a quarter century. For the other values, we employed the same criteria as seen above in the automated process. For another transformation used later on we decided to treat e.g. -199 / 100 as the beginning of century, and e.g. -100 / 199 as the end of the century and did so accordingly in the manual assignment.
285285

286+
As a last step, we switch the in some cases automatically assigned year 0, so that it will be treated as either 1 oder -1:
287+
```{r}
288+
join_dating$DAT_min[which(join_dating$DAT_min == 0)] <- 1
289+
join_dating$DAT_max[which(join_dating$DAT_max == 0)] <- -1
290+
```
291+
286292
We then have to reload the corrected data. The values that we put aside in the `join_dating` `data.frame` beforehand serve as the basis for our new `data.frame` that we use as a look-up table. As the variables were treated as character-strings, we need to convert them to a numeric format first. We append the newly loaded manually assigned values to this data.frame. Again, to keep this process as transparent as possible, we included the *.csv-Table in the "data/prep/" subfolder as "num_dating_edit.csv".
287293

288294
```{r }
@@ -292,7 +298,6 @@ num_dating <- read.csv(file = system.file('extdata', 'num_dating_edit.csv',
292298
encoding = "UTF-8",
293299
row.names = 1,
294300
colClasses = c("character", "character", "integer", "integer"))
295-
296301
join_dating <- join_dating %>%
297302
mutate(DAT_min = as.integer(DAT_min),
298303
DAT_max = as.integer(DAT_max)) %>%
@@ -396,6 +401,7 @@ library(devtools)
396401
install_github("lsteinmann/datplot") # (redacted)
397402
# or
398403
install_local(path = "../datplot_0.1.0.tar.gz")
404+
install_local(path = "../datplot_x.x.x.tar.gz")
399405
```
400406

401407

vignettes/how-to.Rmd

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Density Plots for Dates"
33
output: rmarkdown::html_vignette
44
vignette: >
5-
%\VignetteIndexEntry{Density Plots for Dates}
5+
%\VignetteIndexEntry{datplot: Visualizing chronological distribution}
66
%\VignetteEngine{knitr::rmarkdown}
77
%\VignetteEncoding{UTF-8}
88
bibliography: ../inst/literatur.bib
@@ -48,10 +48,10 @@ kable(Beazley[sample(1:nrow(Beazley), 10, replace = FALSE),])
4848

4949
The table provides two dates for each object. The earliest possible dating (DAT_min) and the latest possible dating (DAT_max). In order to be able to process this to a [density graph](https://en.wikipedia.org/wiki/Kernel_density_estimation), which is the most elegant means of visualization for continuous distributions. (At least if the goal is merely to evaluate changes over time and the probability of object groups dating to a certain point in time, and not to look at actual objects counts, which will be obscured.) The scale we use is only pseudo-continuous, as the data actually comprises of intervals (1 year, or 25 years, etc.), but we nonetheless treat it as a continuous one.
5050

51-
Objects that can be dated with greater confidence should have a larger impact on the overall visualization. The core function of this package (`datsteps()`) produces a column named 'weight' which contains a value that corresponds to one (as the closest possible dating of one year) devided by the time span between the two dating variables. The greater the time span, the lower the weight value. This is a generally accepted method of aoristic analysis ([@ratcliffe_Aoristicanalysisspatial_2000, 671--672 with Fig. 1]).
52-
Secondly, every object is duplicated a number of times equal to the dating range devided by the stepsize-variable. Each duplicate has its own 'date', one single value between the two extremes. The above mentioned weight variable is divided by the number of steps, so that each new fictional object or 'date step' counts only as a fraction of the actual object.
51+
Objects that can be dated with greater confidence should have a larger impact on the overall visualization. The core function of this package (`datsteps()`) produces a column named 'weight' which contains a value that corresponds to one (as the closest possible dating of one year) divided by the time span between the two dating variables. The greater the time span, the lower the weight value. This is a generally accepted method of aoristic analysis ([@ratcliffe_Aoristicanalysisspatial_2000, 671--672 with Fig. 1]).
52+
Secondly, every object is duplicated a number of times equal to the dating range divided by the stepsize-variable. Each duplicate has its own 'date', one single value between the two extremes. The above mentioned weight variable is divided by the number of steps, so that each new fictional object or 'date step' counts only as a fraction of the actual object. With this, we hope to archieve a greater influence of closely dated objects and a higher emphasis on overlap.
5353

54-
This method will not be useful for dating specific context, since any concept of _terminus post/ante quem_ is lost here, which is important on a smaller scale. For the visualization of changes in _trends_ over time, e.g. the popularity of pottery types, or overall peaks in occupation from survey data, the method is ideal.
54+
This method will not be useful for dating specific contexts, since any concept of _terminus post/ante quem_ is lost here, which is important on a smaller scale. It may however be applicable for contexts that are disturbed, as a noticable overlap of objects could indicate the mass original date. For the visualization of changes in _trends_ over time, e.g. the popularity of pottery types, or overall peaks in occupation from survey data, the method seems suitable ([@orton_CatchUnitResearch_2017, 5]).
5555

5656
Other approaches, e.g. using the median date of each object, may often produce similar outcomes, but create other problems. A lot of information is lost on the way when employing averaged or median data, as large amount of loosely dated objects will produce peaks at unreasonable values. (Consider a large amount of objects dated between 600 and 400 BCE all attributed to the year 500 BCE.)
5757

@@ -64,7 +64,22 @@ ggplot(Beazley, aes(x = DAT_mean, fill = Technique)) +
6464

6565
Employing dating steps will even out unreasonable peaks. Note especially the gap between -425 and -300 in the plot above, that is -- in the plot below -- filled with a constant amount of objects in each year. This is due to the data containing large amounts of objects dating from -400 to -300 BCE. Of course, due to duplicating each object numerous times (see table below), the counts represented on the y-axis now inform us of the maximum amount of objects that might be dated to a given bin rather than the actual amount.
6666

67-
The method datplot uses for partitioning steps an be explained as follows: If any given object had been dated as '475 to 425 BC' and steps of 25 years were used for each object, this would result in the creation of three sub-objects with the respective dating of: 475 BC, 450 BC, 425 BC. For an interval of 5 years, the same object would be partitioned into 11 sub-objects, each dating to 475 BC, 470 BC, 465 BC, 460 BC, 455 BC, 450 BC, 445 BC, 440 BC, 435 BC, 430 BC and 425 BC respectively. In order to keep the data comparable, the interval (expressed as the stepsize-variable in the R-package) must be chosen globally for all objects. As the timespan an object is dated to can in many cases not be divided without remainder by the value given as a stepsize (i.e. may only be divided with the modulus of the division being greater than 0), datplot resolves these conflicts by temporarily modifying the size of steps for the objects in question without deviating significantly from the size set beforehand, so that the output is representative and comparable. Objects which are dated to a timespan undercutting the stepsize-variable can either be assigned to one year (for objects dated precisely to one year), to two years (for objects dated to a number of years less than or equal to 40% of the stepsize) or to three years (for objects dated to a number of years exceeding 60% of the stepsize).
67+
The method datplot uses for partitioning steps an be explained as follows: If any given object had been dated as '475 to 425 BC' and steps of 25 years were used for each object, this would result in the creation of three sub-objects with the respective dating of: 475 BC, 450 BC, 425 BC. For an interval of 5 years, the same object would be partitioned into 11 sub-objects, each dating to 475 BC, 470 BC, 465 BC, 460 BC, 455 BC, 450 BC, 445 BC, 440 BC, 435 BC, 430 BC and 425 BC respectively. In order to keep the data comparable, the interval (expressed as the stepsize-variable in the R-package) must be chosen globally for all objects. As the time span an object is dated to can in many cases not be divided without remainder by the value given as a stepsize (i.e. may only be divided with the modulus of the division being greater than 0), datplot resolves these conflicts by temporarily modifying the size of steps for the objects in question without deviating significantly from the size set beforehand, so that the output is representative and comparable. Objects which are dated to a time span undercutting the stepsize-variable can either be assigned to one year (for objects dated precisely to one year), to two years (for objects dated to a number of years less than or equal to 40% of the stepsize) or to three years (for objects dated to a number of years exceeding 60% of the stepsize).
68+
69+
```{r warning = FALSE}
70+
data("Inscr_Bithynia")
71+
Inscr_Bithynia <- Inscr_Bithynia %>%
72+
select(ID, Location, DAT_min, DAT_max) %>%
73+
na.omit()
74+
75+
system.time(inscr_steps <- datsteps(Inscr_Bithynia, stepsize = 25))[3]
76+
system.time(inscr_steps <- datsteps(Inscr_Bithynia, stepsize = "auto"))[3]
77+
```
78+
79+
Using larger step sizes is only recommended if the stepsize of 1 year leads to significant delays in processing while yielding not additional information. If one where to look at a total time span of 10000 years, step sizes of 1 no longer seem very reasonable, as such detailed changes should not be visible or graspable at all, and using steps of 100 years will lead to the same outcome. As classical archaeologists a duration of more than 1000 years mostly exceeds our area of study. We seem to get good results with stepsizes between 1 and 25.
80+
81+
82+
6883

6984
```{r steps1}
7085
library(datplot)

0 commit comments

Comments
 (0)