if (FALSE) {
# Generate example data. Suppose x and y refer to meters distance.
set.seed(10)
(mydata <- data.frame(x = sample(x = 20, size = 20, replace = TRUE) * 20,
y = sample(x = 20, size = 20, replace = TRUE) * 20,
date = as.Date(sort(sample(20, size = 20, replace = TRUE)),
origin = "2018-01-01")
))
# Near Repeat calculation using 0-100 meters and 100-Inf meters, and three
# temporal intervals of 2 days
set.seed(38673)
NRepeat(x = mydata$x, y = mydata$y, time = mydata$date,
sds = c(0,100,Inf), tds = c(0,2,4))
# Add a 'same repeat' spatial interval of 0.001 meters, and use Euclidean
# distance
set.seed(38673)
NRepeat(x = mydata$x, y = mydata$y, time = mydata$date,
sds = c(0,0.001,100,Inf), tds = c(0,2,4),
method = "euclidean")
# Only do 99 replications
set.seed(38673)
NRepeat(x = mydata$x, y = mydata$y, time = mydata$date,
sds = c(0,0.001,100,Inf), tds = c(0,2,4),
method = "euclidean", nrep = 99)
# The plot() function can be used to plot a Heat Map of Near Repeat results
# based on p-values
set.seed(4622)
myoutput <- NRepeat(x = mydata$x, y = mydata$y, time = mydata$date,
sds = c(0,100,200,300,400), td = c(0,1,2,3,4,5))
# The default range of p-values that will be highlighted (0-.05) can be
# adjusted using the 'pvalue_range' parameter. By default the Knox ratios
# are printed in the cells, but this can be adjusted using the 'text'
# parameter. The default is "knox_ratio". Possible values are "observed",
# "knox_ratio", "knox_ratio_median", "pvalues", or NA.
}
Run the code above in your browser using DataLab