Last updated: 2021-11-15

Checks: 7 0

Knit directory: Test/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20210926) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 357a746. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/.DS_Store
    Ignored:    data/Stabiliseur/
    Ignored:    data/json/
    Ignored:    data/plan/
    Ignored:    figure/
    Ignored:    workflowr.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/analysis_tags_soignants.Rmd) and HTML (docs/analysis_tags_soignants.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 357a746 cfcforever 2021-11-15 add new content
html 0472766 cfcforever 2021-11-15 Build site.
Rmd 20d4776 cfcforever 2021-11-15 add new content
html 445800e cfcforever 2021-11-15 Build site.
html 0c2b605 cfcforever 2021-11-15 Build site.
Rmd b561e23 cfcforever 2021-11-15 add new content

load data.json

tagId = c("cf31", "8718", "58b2")
nb_tag = length(tagId)

list_tag <- vector("list", nb_tag)
names(list_tag) = tagId
for (k in 1:nb_tag){
  temp_tag = fromJSON(file = paste0("data/json/tag/", tagId[k], "/position.json"))
  dat <- data.frame(tag = unlist(lapply(temp_tag, function(x){x["tag_id"][[1]]})),
                    x = unlist(lapply(temp_tag, function(x){x["x"][[1]]})),
                    y = unlist(lapply(temp_tag, function(x){x["y"][[1]]})),
                    record_timestamp = unlist(lapply(temp_tag,function(x){x["record_timestamp"][[1]]})))
  dat = dat[order(dat$record_timestamp),]
  dat = cbind.data.frame(dat, convert_date(dat$record_timestamp))
  dat$x = as.numeric(dat$x)/100
  dat$y = as.numeric(dat$y)/100
  list_tag[[k]] = dat
}

general analysis

quality of collecting data

table_tag <- data.frame(tag = tagId)
table_tag$first_record = NA
table_tag$last_record = NA
table_tag$number = NA
table_tag$number_NA = NA
table_tag$ratio_non_NA = NA
# table_tag$freq_1Q = NA
# table_tag$freq_median = NA
# table_tag$freq_3Q = NA


for (k in 1:nb_tag){
  tag = table_tag$tag[k]
  temp = list_tag[tag][[1]]
  temp$diff_ts = c(0, temp$record_timestamp[-1]-temp$record_timestamp[-nrow(temp)])
  
  table_tag$first_record[k] = head(as.character(temp$date),1)
  table_tag$last_record[k] = tail(as.character(temp$date),1)
  table_tag$number[k] = nrow(temp)
  table_tag$number_NA[k] = sum(is.na(temp$x))
  table_tag$ratio_non_NA[k] = round(1-table_tag$number_NA[k]/table_tag$number[k],2)
  # table_tag$freq_1Q[k] = round(quantile(temp$diff_ts, 0.25), 3)
  # table_tag$freq_median[k] = round(quantile(temp$diff_ts, 0.5), 3)
  # table_tag$freq_3Q[k] = round(quantile(temp$diff_ts, 0.75), 3)
}

kable(table_tag) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
tag first_record last_record number number_NA ratio_non_NA
cf31 2021-11-09 14:57:17 2021-11-12 16:23:36 9178 1872 0.80
8718 2021-11-09 14:55:55 2021-11-10 00:38:46 7632 1768 0.77
58b2 2021-11-09 14:55:51 2021-11-13 21:06:38 16198 3126 0.81
list_tag = lapply(list_tag, function(x){cbind(x, data.frame(diff_ts = c(0, x$record_timestamp[-1]-x$record_timestamp[-nrow(x)])))})

nq = 10
table_diff_ts = matrix(NA, nrow = nb_tag, ncol = nq+1)
colnames(table_diff_ts) = paste0(c(0:10)/10*100, "%")
rownames(table_diff_ts) = tagId
for (k in 1:nb_tag){
  tag = tagId[k]
  table_diff_ts[k,] = round(quantile(list_tag[tag][[1]]$diff_ts[-1], c(0:10)/10), 3)
}

kable(table_diff_ts) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
cf31 0 0.001 0.955 0.998 0.999 1 1 1 1.001 1.001 176966.929
8718 0 0.194 0.998 0.999 0.999 1 1 1 1.001 1.001 2913.701
58b2 0 0.001 0.996 0.999 0.999 1 1 1 1.001 1.001 176929.629

analysis by tag

cf31

tag = tagId[1]
dat_tag = list_tag[tag][[1]]
dat_tag = dat_tag[dat_tag$diff_ts>0.1,]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>10)[-1]
dat_tag_sel = dat_tag[unique(c(rows_sel-1, rows_sel, rows_sel+1)),]
dat_tag_sel = dat_tag_sel[order(dat_tag_sel$record_timestamp),]

list_tagr = vector("list", length(rows_sel))
for (k in 1:length(rows_sel)){
  r = rows_sel[k]

  r1 = tail(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))<r),1)
  r2 = head(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))>r),1)

  list_tagr[[k]] = dat_tag[(r1-2):(r2+2),c("tag","x","y","record_timestamp","diff_ts")]
}
nr1 = which(unlist(lapply(list_tagr, nrow))==7)
nr2 = which(unlist(lapply(list_tagr, function(x){sum(is.na(x))==0})))
nr = intersect(nr1, nr2)

cat(length(nr), "situations to be investigated for the tag", tag, "\n")
83 situations to be investigated for the tag cf31 
list_tagr_sel = list_tagr[nr]
dist1 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[3,4]}))
dist2 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[4,5]}))

nq = 10
table_quantile1 = matrix(round(quantile(dist1, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile1) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the last point before the stop and the first point after the stop", "\n")
quantile of distances between the last point before the stop and the first point after the stop 
kable(table_quantile1) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0.139 0.622 1.039 1.413 2.527 3.829 6.162 8.509 10.909 23.736 41.708
table_quantile1 = rbind(table_quantile1, NA)
for (i in 1:ncol(table_quantile1)){
  table_quantile1[2,i] = which.min(abs(dist1 - as.numeric(table_quantile1[1,i])))
}

nq = 10
table_quantile2 = matrix(round(quantile(dist2, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile2) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the first two points after the stop", "\n")
quantile of distances between the first two points after the stop 
kable(table_quantile2) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0 0.037 0.08 0.101 0.147 0.233 0.298 0.36 0.555 0.709 1.085
for (k in 1:ncol(table_quantile1)){
  cat("\n")
  cat("### ", colnames(table_quantile1)[k], "\n")
  j = table_quantile1[2,k]
  tagr = list_tagr[[nr[j]]]

  print(kable(tagr) %>%
    kable_styling(bootstrap_options = "striped", full_width = T))

  q <- p + 
    geom_point(data = tagr[1:3,], aes(x=x,y=y, col = "1-before"), size = 0.5) + 
    geom_point(data = tagr[5:7,], aes(x=x,y=y, col = "3-after"), size = 0.5) +
    geom_point(data = tagr[4,], aes(x=x,y=y, col = "2-start"), size = 0.5) + 
    coord_fixed(ratio=1, xlim = c((min(tagr$x)-1),(max(tagr$x)+1)), ylim = c((min(tagr$y)-1),(max(tagr$y)+1))) +
    theme(legend.title = element_blank()) +
    labs(x="", y="")
  print(q)
  cat("\n")
}

0%

tag x y record_timestamp diff_ts
5645 cf31 9.99 23.14 1636515482 1.0000000
5646 cf31 9.96 23.15 1636515483 1.0000000
5647 cf31 9.84 23.34 1636515484 0.9989998
5648 cf31 9.89 23.21 1636515530 46.5010002
5649 cf31 9.88 23.17 1636515531 1.0019999
5650 cf31 9.87 23.27 1636515532 0.9990001
5651 cf31 9.91 23.16 1636515533 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

10%

tag x y record_timestamp diff_ts
2161 cf31 10.95 24.47 1636479784 1.0010002
2162 cf31 10.66 24.31 1636479785 1.0000000
2163 cf31 10.18 24.10 1636479786 0.9989998
2164 cf31 10.16 23.48 1636479884 97.8000002
2165 cf31 10.16 23.51 1636479885 1.0000000
2166 cf31 9.98 23.50 1636479886 1.0000000
2167 cf31 9.83 23.48 1636479887 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

20%

tag x y record_timestamp diff_ts
845 cf31 9.55 4.66 1636472230 0.9989998
846 cf31 9.52 4.54 1636472231 1.0000000
847 cf31 9.48 4.59 1636472232 1.0010002
848 cf31 9.10 5.55 1636472541 308.8020000
849 cf31 9.11 5.65 1636472542 0.9989998
850 cf31 9.11 5.66 1636472543 0.9990001
851 cf31 9.13 5.58 1636472544 1.0009999

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

30%

tag x y record_timestamp diff_ts
494 cf31 -11.82 -9.83 1636469873 2.001
495 cf31 -12.18 -9.90 1636469874 1.000
496 cf31 -12.33 -10.04 1636469875 1.000
497 cf31 -13.14 -11.27 1636470039 164.199
498 cf31 -13.24 -11.35 1636470040 1.000
499 cf31 -13.20 -11.09 1636470041 1.000
500 cf31 -13.05 -10.81 1636470042 1.000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

40%

tag x y record_timestamp diff_ts
6252 cf31 7.59 13.23 1636527458 1.0009999
6253 cf31 7.71 13.35 1636527459 1.0000000
6254 cf31 7.44 13.09 1636527460 1.0000000
6255 cf31 8.85 10.96 1636527601 141.2000000
6256 cf31 8.70 11.04 1636527602 0.9990001
6257 cf31 8.61 11.04 1636527603 1.0000000
6258 cf31 8.50 11.07 1636527604 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

50%

tag x y record_timestamp diff_ts
1231 cf31 6.52 9.45 1636474424 1.0000000
1232 cf31 6.68 9.43 1636474425 0.9990001
1233 cf31 6.84 9.41 1636474426 1.0030000
1234 cf31 8.25 5.85 1636474797 371.1010001
1235 cf31 8.12 5.78 1636474798 0.9970000
1236 cf31 8.03 5.74 1636474799 0.9579999
1237 cf31 7.98 5.70 1636474800 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

60%

tag x y record_timestamp diff_ts
607 cf31 7.09 11.17 1636471626 1.0019999
608 cf31 7.07 11.16 1636471627 0.9990001
609 cf31 6.98 11.18 1636471628 1.0009999
610 cf31 8.49 5.35 1636471741 113.9000001
611 cf31 8.52 5.36 1636471742 0.9979999
612 cf31 8.53 5.37 1636471743 1.0000000
613 cf31 8.53 5.40 1636471744 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

70%

tag x y record_timestamp diff_ts
1386 cf31 13.34 5.97 1636475657 0.9979999
1387 cf31 13.45 5.81 1636475658 0.9989998
1388 cf31 13.67 5.68 1636475659 0.9989998
1389 cf31 8.02 12.03 1636476052 393.1010001
1390 cf31 8.00 12.00 1636476053 0.9960001
1391 cf31 8.06 12.03 1636476054 0.9550002
1392 cf31 8.18 12.04 1636476055 0.9970000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

80%

tag x y record_timestamp diff_ts
6687 cf31 10.74 14.94 1636540289 1.0039999
6688 cf31 10.82 15.01 1636540290 0.9979999
6689 cf31 10.62 14.85 1636540291 0.9980001
6690 cf31 12.37 25.67 1636541030 739.2990000
6691 cf31 12.39 25.33 1636541031 1.0009999
6692 cf31 12.43 24.79 1636541032 1.0009999
6693 cf31 12.54 24.02 1636541033 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

90%

tag x y record_timestamp diff_ts
6132 cf31 5.12 6.34 1636526127 1.0000000
6133 cf31 5.16 6.39 1636526128 1.0030000
6134 cf31 5.23 6.52 1636526129 0.9970000
6135 cf31 10.84 29.97 1636526798 668.9010000
6136 cf31 10.88 29.83 1636526799 0.9989998
6137 cf31 10.83 29.69 1636526800 0.9989998
6138 cf31 10.68 29.54 1636526801 1.0019999

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

100%

tag x y record_timestamp diff_ts
4494 cf31 -15.77 -19.43 1636500306 1.0000000
4495 cf31 -15.78 -19.41 1636500307 1.0000000
4496 cf31 -15.80 -19.42 1636500308 1.0000000
4497 cf31 9.10 14.04 1636500600 292.3009999
4498 cf31 8.93 13.79 1636500601 0.9990001
4499 cf31 8.88 13.71 1636500602 0.9990001
4500 cf31 8.83 13.65 1636500603 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15

8718

tag = tagId[2]
dat_tag = list_tag[tag][[1]]
dat_tag = dat_tag[dat_tag$diff_ts>0.1,]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>10)[-1]
dat_tag_sel = dat_tag[unique(c(rows_sel-1, rows_sel, rows_sel+1)),]
dat_tag_sel = dat_tag_sel[order(dat_tag_sel$record_timestamp),]

list_tagr = vector("list", length(rows_sel))
for (k in 1:length(rows_sel)){
  r = rows_sel[k]

  r1 = tail(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))<r),1)
  r2 = head(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))>r),1)

  list_tagr[[k]] = dat_tag[(r1-2):(r2+2),c("tag","x","y","record_timestamp","diff_ts")]
}
nr1 = which(unlist(lapply(list_tagr, nrow))==7)
nr2 = which(unlist(lapply(list_tagr, function(x){sum(is.na(x))==0})))
nr = intersect(nr1, nr2)

cat(length(nr), "situations to be investigated for the tag", tag, "\n")
47 situations to be investigated for the tag 8718 
list_tagr_sel = list_tagr[nr]
dist1 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[3,4]}))
dist2 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[4,5]}))

nq = 10
table_quantile1 = matrix(round(quantile(dist1, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile1) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the last point before the stop and the first point after the stop", "\n")
quantile of distances between the last point before the stop and the first point after the stop 
kable(table_quantile1) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0.142 0.398 0.52 0.87 1.182 1.543 2.11 2.39 3.51 5.518 8.842
table_quantile1 = rbind(table_quantile1, NA)
for (i in 1:ncol(table_quantile1)){
  table_quantile1[2,i] = which.min(abs(dist1 - as.numeric(table_quantile1[1,i])))
}

nq = 10
table_quantile2 = matrix(round(quantile(dist2, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile2) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the first two points after the stop", "\n")
quantile of distances between the first two points after the stop 
kable(table_quantile2) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0.032 0.06 0.121 0.145 0.19 0.269 0.299 0.349 0.528 0.627 1.066
for (k in 1:ncol(table_quantile1)){
  cat("\n")
  cat("### ", colnames(table_quantile1)[k], "\n")
  j = table_quantile1[2,k]
  tagr = list_tagr[[nr[j]]]

  print(kable(tagr) %>%
    kable_styling(bootstrap_options = "striped", full_width = T))

  q <- p + 
    geom_point(data = tagr[1:3,], aes(x=x,y=y, col = "1-before"), size = 0.5) + 
    geom_point(data = tagr[5:7,], aes(x=x,y=y, col = "3-after"), size = 0.5) +
    geom_point(data = tagr[4,], aes(x=x,y=y, col = "2-start"), size = 0.5) + 
    coord_fixed(ratio=1, xlim = c((min(tagr$x)-1),(max(tagr$x)+1)), ylim = c((min(tagr$y)-1),(max(tagr$y)+1))) +
    theme(legend.title = element_blank()) +
    labs(x="", y="")
  print(q)
  cat("\n")
}

0%

tag x y record_timestamp diff_ts
2745 8718 9.38 10.69 1636477710 0.9980001
2746 8718 9.42 10.66 1636477711 1.0000000
2747 8718 9.46 10.63 1636477712 1.0000000
2748 8718 9.35 10.54 1636478017 304.7000000
2749 8718 9.30 10.56 1636478018 1.0000000
2750 8718 9.33 10.57 1636478019 0.9989998
2751 8718 9.36 10.57 1636478020 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

10%

tag x y record_timestamp diff_ts
4628 8718 9.91 12.29 1636484731 1.0000000
4629 8718 10.03 12.35 1636484732 1.0000000
4630 8718 10.09 12.39 1636484733 1.0000000
4631 8718 9.66 12.46 1636485234 500.5009999
4632 8718 9.70 12.46 1636485235 1.0010002
4633 8718 9.71 12.42 1636485236 0.9989998
4634 8718 9.67 12.37 1636485237 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

20%

tag x y record_timestamp diff_ts
4095 8718 9.61 11.97 1636481709 0.997
4096 8718 9.72 12.07 1636481710 1.001
4097 8718 9.84 12.15 1636481711 1.001
4098 8718 10.09 12.59 1636481839 128.398
4099 8718 10.04 12.51 1636481840 1.000
4100 8718 10.05 12.49 1636481841 1.000
4101 8718 10.02 12.45 1636481842 1.001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

30%

tag x y record_timestamp diff_ts
3462 8718 10.04 12.13 1636479309 1.0010002
3463 8718 9.98 12.07 1636479310 0.9989998
3464 8718 9.89 11.98 1636479311 1.0010002
3465 8718 10.03 12.84 1636479398 86.4010000
3466 8718 9.90 12.60 1636479399 0.9989998
3467 8718 9.83 12.47 1636479400 1.0000000
3468 8718 9.77 12.37 1636479401 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

40%

tag x y record_timestamp diff_ts
3844 8718 9.41 11.81 1636480895 1.0019999
3845 8718 9.43 11.87 1636480896 0.9990001
3846 8718 9.96 12.41 1636480897 1.0000000
3847 8718 10.32 13.47 1636480916 19.3989999
3848 8718 10.22 13.17 1636480917 1.0000000
3849 8718 10.14 12.94 1636480918 1.0020001
3850 8718 9.99 12.73 1636480919 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

50%

tag x y record_timestamp diff_ts
2140 8718 2.98 28.64 1636473412 1.0000000
2141 8718 2.12 28.90 1636473413 1.0000000
2142 8718 1.46 28.78 1636473414 1.0000000
2143 8718 0.33 27.73 1636473492 77.6020000
2144 8718 0.27 27.68 1636473493 0.9980001
2145 8718 0.21 27.72 1636473494 1.0000000
2146 8718 0.12 27.90 1636473495 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

60%

tag x y record_timestamp diff_ts
5348 8718 9.70 12.03 1636490325 0.9990001
5349 8718 9.73 12.04 1636490326 1.0000000
5350 8718 9.82 12.05 1636490327 1.0000000
5351 8718 7.74 12.44 1636490358 30.8989999
5352 8718 7.76 12.11 1636490359 1.0000000
5353 8718 8.14 11.64 1636490360 1.0000000
5354 8718 8.29 11.35 1636490361 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

70%

tag x y record_timestamp diff_ts
5857 8718 3.80 29.88 1636493572 1.0000000
5858 8718 3.76 29.91 1636493573 1.0000000
5859 8718 3.32 28.89 1636493574 1.0000000
5860 8718 5.63 28.92 1636493601 27.0990000
5861 8718 6.61 28.87 1636493602 1.0000000
5862 8718 7.75 28.74 1636493603 1.0000000
5863 8718 8.85 28.36 1636493604 0.9989998

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

80%

tag x y record_timestamp diff_ts
5985 8718 10.63 12.28 1636493792 1.0000000
5986 8718 10.55 12.25 1636493793 1.0000000
5987 8718 10.52 12.22 1636493794 1.0000000
5988 8718 8.39 15.11 1636494268 474.1010001
5989 8718 8.93 15.10 1636494269 1.0000000
5990 8718 9.52 15.26 1636494270 1.0009999
5991 8718 10.06 15.39 1636494271 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

90%

tag x y record_timestamp diff_ts
6019 8718 11.91 15.62 1636494299 0.9990001
6020 8718 11.86 15.59 1636494300 1.0020001
6021 8718 11.81 15.57 1636494301 0.9989998
6022 8718 6.97 13.64 1636494371 70.0030000
6023 8718 7.02 13.60 1636494372 0.9970000
6024 8718 7.56 13.84 1636494373 0.9989998
6025 8718 7.58 13.45 1636494374 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

100%

tag x y record_timestamp diff_ts
4239 8718 8.59 10.52 1636482538 1.0010002
4240 8718 8.49 10.86 1636482539 1.0000000
4241 8718 8.41 11.17 1636482540 1.0000000
4242 8718 0.16 7.99 1636482562 22.4009998
4243 8718 -0.53 7.65 1636482563 0.9980001
4244 8718 -1.52 7.66 1636482564 1.0000000
4245 8718 -2.65 7.36 1636482565 1.0009999

Version Author Date
0472766 cfcforever 2021-11-15

58b2

tag = tagId[3]
dat_tag = list_tag[tag][[1]]
dat_tag = dat_tag[dat_tag$diff_ts>0.1,]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>10)[-1]
dat_tag_sel = dat_tag[unique(c(rows_sel-1, rows_sel, rows_sel+1)),]
dat_tag_sel = dat_tag_sel[order(dat_tag_sel$record_timestamp),]

list_tagr = vector("list", length(rows_sel))
for (k in 1:length(rows_sel)){
  r = rows_sel[k]

  r1 = tail(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))<r),1)
  r2 = head(which(!is.na(dat_tag$x) & as.numeric(rownames(dat_tag))>r),1)

  list_tagr[[k]] = dat_tag[(r1-2):(r2+2),c("tag","x","y","record_timestamp","diff_ts")]
}
nr1 = which(unlist(lapply(list_tagr, nrow))==7)
nr2 = which(unlist(lapply(list_tagr, function(x){sum(is.na(x))==0})))
nr = intersect(nr1, nr2)

cat(length(nr), "situations to be investigated for the tag", tag, "\n")
160 situations to be investigated for the tag 58b2 
list_tagr_sel = list_tagr[nr]
dist1 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[3,4]}))
dist2 = unlist(lapply(list_tagr_sel, function(x){as.matrix(dist(x[,c("x","y")]))[4,5]}))

nq = 10
table_quantile1 = matrix(round(quantile(dist1, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile1) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the last point before the stop and the first point after the stop", "\n")
quantile of distances between the last point before the stop and the first point after the stop 
kable(table_quantile1) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0.045 0.507 0.794 1.11 1.887 2.391 4.299 7.403 13.344 19.254 35.676
table_quantile1 = rbind(table_quantile1, NA)
for (i in 1:ncol(table_quantile1)){
  table_quantile1[2,i] = which.min(abs(dist1 - as.numeric(table_quantile1[1,i])))
}

nq = 10
table_quantile2 = matrix(round(quantile(dist2, 0:10/10),3), nrow = 1, ncol = nq+1)
colnames(table_quantile2) = paste0(c(0:10)/10*100, "%")
cat("quantile of distances between the first two points after the stop", "\n")
quantile of distances between the first two points after the stop 
kable(table_quantile2) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
0.01 0.064 0.09 0.138 0.188 0.233 0.281 0.329 0.455 0.714 33.169
for (k in 1:ncol(table_quantile1)){
  cat("\n")
  cat("### ", colnames(table_quantile1)[k], "\n")
  j = table_quantile1[2,k]
  tagr = list_tagr[[nr[j]]]

  print(kable(tagr) %>%
    kable_styling(bootstrap_options = "striped", full_width = T))

  q <- p + 
    geom_point(data = tagr[1:3,], aes(x=x,y=y, col = "1-before"), size = 0.5) + 
    geom_point(data = tagr[5:7,], aes(x=x,y=y, col = "3-after"), size = 0.5) +
    geom_point(data = tagr[4,], aes(x=x,y=y, col = "2-start"), size = 0.5) + 
    coord_fixed(ratio=1, xlim = c((min(tagr$x)-1),(max(tagr$x)+1)), ylim = c((min(tagr$y)-1),(max(tagr$y)+1))) +
    theme(legend.title = element_blank()) +
    labs(x="", y="")
  print(q)
  cat("\n")
}

0%

tag x y record_timestamp diff_ts
6912 58b2 10.24 12.62 1636731130 0.9970000
6913 58b2 10.11 12.64 1636731131 0.9990001
6914 58b2 9.81 12.42 1636731132 0.9980001
6915 58b2 9.77 12.44 1636731323 191.8000000
6916 58b2 9.74 12.46 1636731324 1.0000000
6917 58b2 9.71 12.51 1636731325 1.0010002
6918 58b2 9.69 12.51 1636731326 0.9989998

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

10%

tag x y record_timestamp diff_ts
1695 58b2 8.09 20.54 1636481747 0.9990001
1696 58b2 8.04 20.60 1636481748 1.0000000
1697 58b2 8.01 20.62 1636481749 0.9990001
1698 58b2 8.15 21.11 1636481803 54.5019999
1699 58b2 8.17 20.81 1636481804 0.9990001
1700 58b2 8.10 20.77 1636481805 1.0000000
1701 58b2 8.20 20.48 1636481806 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

20%

tag x y record_timestamp diff_ts
6841 58b2 9.89 12.87 1636729914 1.0009999
6842 58b2 9.90 12.87 1636729915 0.9990001
6843 58b2 9.90 12.88 1636729916 1.0009999
6844 58b2 10.52 13.38 1636730238 321.2010000
6845 58b2 10.34 13.21 1636730239 0.9990001
6846 58b2 10.19 13.09 1636730240 1.0000000
6847 58b2 10.10 13.02 1636730241 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

30%

tag x y record_timestamp diff_ts
13092 58b2 8.72 15.77 1636824052 1.0000000
13093 58b2 8.80 15.79 1636824053 0.9979999
13094 58b2 8.82 15.82 1636824054 1.0020001
13095 58b2 7.90 16.44 1636824109 54.7010000
13096 58b2 7.79 15.63 1636824110 0.9970000
13097 58b2 8.15 15.39 1636824111 1.0009999
13098 58b2 8.30 14.67 1636824112 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

40%

tag x y record_timestamp diff_ts
4686 58b2 -5.97 11.76 1636536139 1.0000000
4687 58b2 -5.95 11.77 1636536140 1.0100000
4688 58b2 -5.99 11.79 1636536141 0.9920001
4689 58b2 -4.14 12.31 1636536327 185.6970000
4690 58b2 -4.15 12.39 1636536328 0.9989998
4691 58b2 -4.16 12.48 1636536329 1.0000000
4692 58b2 -4.12 12.45 1636536330 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

50%

tag x y record_timestamp diff_ts
9341 58b2 7.46 17.32 1636786707 1.0000000
9342 58b2 7.48 17.33 1636786708 0.9990001
9343 58b2 7.40 17.27 1636786709 1.0000000
9344 58b2 9.16 18.92 1636786841 131.8009999
9345 58b2 9.14 18.86 1636786842 0.9990001
9346 58b2 9.15 18.88 1636786843 1.0000000
9347 58b2 9.16 18.86 1636786844 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

60%

tag x y record_timestamp diff_ts
1632 58b2 10.73 10.76 1636481181 0.9990001
1633 58b2 10.69 10.75 1636481182 1.0000000
1634 58b2 10.65 10.73 1636481183 1.0000000
1635 58b2 8.24 14.28 1636481592 408.6990001
1636 58b2 7.97 14.66 1636481593 1.0079999
1637 58b2 7.85 15.45 1636481594 0.9930000
1638 58b2 7.70 16.52 1636481595 0.9990001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

70%

tag x y record_timestamp diff_ts
2259 58b2 10.59 19.05 1636486058 1.0000000
2260 58b2 10.27 18.95 1636486059 1.0019999
2261 58b2 9.89 18.93 1636486060 0.9990001
2262 58b2 7.74 11.90 1636486295 235.2000000
2263 58b2 7.94 11.62 1636486296 0.9990001
2264 58b2 8.45 10.92 1636486297 1.0000000
2265 58b2 8.98 10.84 1636486298 1.0009999

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

80%

tag x y record_timestamp diff_ts
4239 58b2 -2.63 -3.63 1636533507 1.0009999
4240 58b2 -2.70 -3.53 1636533508 1.0000000
4241 58b2 -2.77 -3.46 1636533509 0.9990001
4242 58b2 -11.78 -13.26 1636533867 358.0009999
4243 58b2 -11.78 -13.27 1636533868 0.9990001
4244 58b2 -11.81 -13.26 1636533869 0.9990001
4245 58b2 -11.76 -13.20 1636533870 0.9979999

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

90%

tag x y record_timestamp diff_ts
6679 58b2 -3.70 -20.74 1636729540 1.0000000
6680 58b2 -3.74 -20.84 1636729541 1.0010002
6681 58b2 -3.68 -20.89 1636729542 0.9989998
6682 58b2 -8.69 -2.39 1636729683 141.2020001
6683 58b2 -8.65 -1.27 1636729684 1.0530000
6684 58b2 -8.73 0.02 1636729685 0.9450002
6685 58b2 -8.95 1.36 1636729686 0.9560001

Version Author Date
0472766 cfcforever 2021-11-15
0c2b605 cfcforever 2021-11-15

100%

tag x y record_timestamp diff_ts
6942 58b2 9.72 12.64 1636731350 1.0009999
6943 58b2 9.66 12.60 1636731351 1.0000000
6944 58b2 9.99 12.88 1636731352 1.0000000
6945 58b2 -8.73 -17.49 1636731964 611.8010001
6946 58b2 -9.11 -17.89 1636731965 0.9960001
6947 58b2 -9.09 -18.26 1636731966 0.9990001
6948 58b2 -9.08 -18.79 1636731967 1.0000000

Version Author Date
0472766 cfcforever 2021-11-15

sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] scales_1.1.1     DT_0.19          readxl_1.3.1     lubridate_1.7.10
 [5] dplyr_1.0.5      nnet_7.3-15      kableExtra_1.3.4 rjson_0.2.20    
 [9] cowplot_1.1.1    gifski_1.4.3-1   gganimate_1.0.7  ggplot2_3.3.5   
[13] workflowr_1.6.2 

loaded via a namespace (and not attached):
 [1] progress_1.2.2    tidyselect_1.1.0  xfun_0.22         bslib_0.2.4      
 [5] purrr_0.3.4       colorspace_2.0-0  vctrs_0.3.7       generics_0.1.0   
 [9] viridisLite_0.4.0 htmltools_0.5.1.1 yaml_2.2.1        utf8_1.2.1       
[13] rlang_0.4.10      jquerylib_0.1.3   later_1.1.0.1     pillar_1.6.0     
[17] glue_1.4.2        withr_2.4.1       tweenr_1.0.2      lifecycle_1.0.0  
[21] stringr_1.4.0     cellranger_1.1.0  munsell_0.5.0     gtable_0.3.0     
[25] rvest_1.0.0       htmlwidgets_1.5.3 evaluate_0.14     labeling_0.4.2   
[29] knitr_1.32        httpuv_1.5.5      fansi_0.4.2       highr_0.8        
[33] Rcpp_1.0.7        promises_1.2.0.1  webshot_0.5.2     jsonlite_1.7.2   
[37] systemfonts_1.0.1 farver_2.1.0      fs_1.5.0          hms_1.0.0        
[41] digest_0.6.27     stringi_1.5.3     grid_4.0.5        rprojroot_2.0.2  
[45] tools_4.0.5       magrittr_2.0.1    sass_0.3.1        tibble_3.1.0     
[49] crayon_1.4.1      whisker_0.4       pkgconfig_2.0.3   ellipsis_0.3.1   
[53] xml2_1.3.2        prettyunits_1.1.1 svglite_2.0.0     rmarkdown_2.10   
[57] httr_1.4.2        rstudioapi_0.13   R6_2.5.0          git2r_0.28.0     
[61] compiler_4.0.5