| resolve_probabilistically | R Documentation |
These functions resolve messydates by drawing one precise date at random
from the dates that each value can be.
random() expands all elements of the vector into one combined set of
dates and draws a single value from it.
vrandom() draws from each element separately, and so returns a vector
of the same length as the input.
Repeated draws give a distribution of results, which shows how much an
analysis depends on the imprecision of the dates.
random(..., na.rm = TRUE)
## S3 method for class 'mdate'
random(..., na.rm = TRUE, approx_range = 0, uncertain_p = 1)
vrandom(..., na.rm = TRUE)
## S3 method for class 'mdate'
vrandom(..., na.rm = TRUE, approx_range = 0, uncertain_p = 1)
... |
a mdate object |
na.rm |
Should NAs be removed? FALSE by default.
As in base R, with |
approx_range |
The range by which to widen approximate values ( |
uncertain_p |
The probability that an uncertain value ( |
By default, each date that a value can be has the same chance of being
drawn.
For a [] ("one member of") set, this is a draw from the candidates
themselves.
For a {} ("all members of") set, it is a draw of one of the
occurrences.
The arguments approx_range and uncertain_p change the draw for
approximate and uncertain values.
An mdate of precise dates or date-times.
The v*() functions give one value for each element of x,
with NA for a missing value and for the empty set, {}.
The other functions give one value for the whole vector.
The two annotations have different effects on a random draw.
An approximate value (~) can be outside the dates that it names.
With a positive approx_range, the dates it names (the core) have a
weight of 1, and the dates that approx_range adds on each side
have a weight that falls linearly to 0.
A range widens at each end by the marks of that end, so the weight is
1 across the range and falls to 0 beyond an approximate end.
The core and the full range are the "yolk" and the "egg" of the egg-yolk
model of regions with indeterminate boundaries (Cohn and Gotts 1996).
The linear fall between them is an assumption of this package.
An uncertain value (?) is a record that the source itself doubts.
The doubt is about whether the record is correct at all,
so it does not change the dates that the value can be.
Instead, uncertain_p gives the probability that the record is correct.
Repeated draws then show how much a result depends on doubtful records.
Cohn, A. G. and Gotts, N. M. (1996). "The 'egg-yolk' representation of regions with indeterminate boundaries". In P. A. Burrough and A. U. Frank (eds.), Geographic Objects with Indeterminate Boundaries, GISDATA 2, pp. 171-187. London: Taylor & Francis.
d <- as_messydate(c("2008-03-25", "?2012-02-27", "2001-01?", "2001~",
"2001-01-01..2001-02-02", "{2001-01-01,2001-02-02}",
"{2001-01,2001-02-02}", "2008-XX-31", "-0050-01-01"))
d
random(d)
vrandom(d)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.