Last updated: 2021-12-07

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 4e7a3df. 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:    analysis/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/Stabiliseur/
    Ignored:    data/json/
    Ignored:    data/plan/
    Ignored:    data/stab/.DS_Store
    Ignored:    figure/
    Ignored:    workflowr.R

Untracked files:
    Untracked:  analysis/analysis_tags_soignants_20211207.Rmd

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_20211129.Rmd) and HTML (docs/analysis_tags_soignants_20211129.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
html d7231ed cfcforever 2021-12-01 Build site.
Rmd a8d86fe cfcforever 2021-12-01 add new analysis
html 164119c cfcforever 2021-11-30 Build site.
Rmd 5f9dda1 cfcforever 2021-11-30 add new analysis

load data.json

tagId = c("d9b7", "c901", "da0c")
nb_tag = length(tagId)

today = "2021-11-25"
json_data = fromJSON(file = paste0("data/json/", today, "/position.json"))

dat <- data.frame(tag = unlist(lapply(json_data, function(x){x["tag_id"][[1]]})),
                  x = unlist(lapply(json_data, function(x){x["x"][[1]]})),
                  y = unlist(lapply(json_data, function(x){x["y"][[1]]})),
                  record_timestamp = unlist(lapply(json_data, 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 <- split(dat, dat$tag)
list_tag = list_tag[tagId]

list_tag = lapply(list_tag, function(x){
  x$diff_ts = c(0, x$record_timestamp[-1]-x$record_timestamp[-nrow(x)])
  x = x[c(1,which(x$diff_ts>=0.1)),]
})

analysis by tag

d9b7

tag = tagId[1]
dat_tag = list_tag[tag][[1]]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>5)
nr = c()
nd = c()
ns = c()
for (k in 1:length(rows_sel)){
  ki = rows_sel[k]
  s = dat_tag[(ki-1):ki,c("x","y")]
  if (sum(is.na(s))==0){
    nr = c(nr, ki)
    ns = c(ns, dat_tag$diff_ts[ki])
    d = dist(s)
    nd = c(nd, d)
  }
}
cat(length(nr), "situations to be investigated for the tag", tag, "\n")
62 situations to be investigated for the tag d9b7 
nq = 10
table_quantile1 = matrix(round(quantile(nd, 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.091 0.261 0.428 0.652 1.034 1.479 1.978 2.451 4.448 8.542 14.361
table_output = data.frame(diff_ts = ns, dist = nd)
table_output = table_output[order(table_output$dist, decreasing = T),]
kable(table_output) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
diff_ts dist
1 18.099 14.3608809
39 687.701 13.3579227
56 14.100 11.4989565
58 14.099 11.4399869
47 6.258 9.4228074
52 8.200 8.7814577
31 6.798 8.5881896
28 842.002 8.1272382
26 828.101 7.7726186
17 28.500 6.1164777
16 11.599 4.9469283
20 78.400 4.8882921
55 569.002 4.6383833
48 161.299 3.6876280
32 14.001 3.5737515
36 10.800 3.2457973
57 141.001 2.6757616
7 8.600 2.4932709
37 9.000 2.4801814
25 61.800 2.3830443
30 540.095 2.3544001
34 100.640 2.2340322
2 29.900 2.1828880
40 77.747 2.1770622
59 85.000 2.0220040
60 7.802 1.9108637
3 179.853 1.8271836
18 454.401 1.8015549
54 38.600 1.7848809
21 276.801 1.5417522
24 33.902 1.5073487
53 125.302 1.4500000
51 417.201 1.3476646
13 48.299 1.2192621
6 9.598 1.1692733
35 546.800 1.1111256
27 54.002 1.0770330
46 33.700 1.0046392
50 81.001 0.9992497
4 49.395 0.8984431
5 90.001 0.7937884
12 44.599 0.7627582
14 58.400 0.6525335
8 25.600 0.6519202
45 19.500 0.6503076
44 286.047 0.6413267
19 59.100 0.5234501
23 9.999 0.5092151
10 103.198 0.4825971
33 13.800 0.4148494
49 86.199 0.4140048
22 134.200 0.3312099
43 94.846 0.3201562
38 6.999 0.2968164
15 20.700 0.2842534
61 80.501 0.2580698
9 160.600 0.2220360
11 6.802 0.1655295
29 451.143 0.1529706
62 11.401 0.1486607
42 5.399 0.1104536
41 6.201 0.0905539

c901

tag = tagId[2]
dat_tag = list_tag[tag][[1]]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>5)
nr = c()
nd = c()
ns = c()
for (k in 1:length(rows_sel)){
  ki = rows_sel[k]
  s = dat_tag[(ki-1):ki,c("x","y")]
  if (sum(is.na(s))==0){
    nr = c(nr, ki)
    ns = c(ns, dat_tag$diff_ts[ki])
    d = dist(s)
    nd = c(nd, d)
  }
}
cat(length(nr), "situations to be investigated for the tag", tag, "\n")
50 situations to be investigated for the tag c901 
nq = 10
table_quantile1 = matrix(round(quantile(nd, 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.146 1.784 3.266 5.142 6.595 8.096 10.32 11.097 12.991 20.45 49.738
table_output = data.frame(diff_ts = ns, dist = nd)
table_output = table_output[order(table_output$dist, decreasing = T),]
kable(table_output) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
diff_ts dist
29 791.902 49.7376005
36 268.901 22.3149569
43 53.301 21.9189826
48 2039.899 21.6864059
47 715.902 20.9640645
24 263.400 20.3925109
45 13.402 18.6367647
11 116.803 17.7973032
3 33.602 16.1389281
4 130.901 13.4619947
22 207.098 12.8728940
38 312.900 12.3338113
2 306.000 11.8236247
32 432.600 11.6313069
9 350.102 11.3186086
20 8.400 11.0021861
1 72.600 10.9376643
23 116.300 10.6821908
35 9.001 10.6092271
42 203.501 10.3257445
33 105.603 10.3168648
28 7.002 10.0611182
21 143.802 9.6852981
34 5.600 8.2324298
40 38.945 8.1751453
26 53.400 8.0170069
8 60.502 7.5323834
16 45.701 7.3753983
37 6.400 7.0520706
6 71.401 6.7701846
44 5.298 6.3316743
14 48.399 5.9092216
18 12.802 5.8252639
46 17.102 5.3021222
15 6.201 5.2049976
10 5.401 4.9955180
19 47.702 4.5394383
13 9.800 4.1600481
17 130.600 3.4321131
7 24.801 3.2766599
12 76.702 3.2236780
25 14.201 2.8554509
41 6.245 2.4201240
50 80.600 2.4030189
5 11.801 1.8569060
39 32.398 1.1307077
49 29.401 0.7158911
31 6.999 0.3255764
30 6.401 0.3041381
27 312.900 0.1456022

da0c

tag = tagId[3]
dat_tag = list_tag[tag][[1]]
rownames(dat_tag) = 1:nrow(dat_tag)

rows_sel = which(dat_tag$diff_ts>5)
nr = c()
nd = c()
ns = c()
for (k in 1:length(rows_sel)){
  ki = rows_sel[k]
  s = dat_tag[(ki-1):ki,c("x","y")]
  if (sum(is.na(s))==0){
    nr = c(nr, ki)
    ns = c(ns, dat_tag$diff_ts[ki])
    d = dist(s)
    nd = c(nd, d)
  }
}
cat(length(nr), "situations to be investigated for the tag", tag, "\n")
80 situations to be investigated for the tag da0c 
nq = 10
table_quantile1 = matrix(round(quantile(nd, 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.063 0.249 0.61 0.945 1.211 1.565 2.14 2.559 3.622 9.073 42.737
table_output = data.frame(diff_ts = ns, dist = nd)
table_output = table_output[order(table_output$dist, decreasing = T),]
kable(table_output) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
diff_ts dist
13 98.200 42.7367582
60 303.100 22.2295119
24 14.099 20.8967988
9 37.601 20.1391410
25 14.102 18.1160978
66 20.901 11.3417856
44 487.803 10.0488606
77 68.244 9.2045749
8 69.601 9.0581510
3 227.103 7.3518501
12 6.801 6.9564718
50 110.901 6.4660653
45 49.102 6.3842384
2 6.799 5.4813137
70 3330.696 5.0235446
76 363.800 3.7403743
49 6.401 3.5924365
54 265.801 3.2345943
55 22.161 2.8706271
65 872.303 2.8595454
7 52.000 2.7561749
79 33.401 2.6673208
52 593.900 2.6309694
71 51.002 2.5656188
36 30.202 2.5554843
73 420.232 2.4300206
62 6.600 2.4101452
6 538.400 2.4060133
28 105.102 2.3601907
5 6.301 2.3560136
35 7.800 2.2493110
38 15.302 2.2261177
63 7.999 2.0827386
11 403.302 2.0185391
72 43.901 1.9964218
33 10.399 1.9275373
32 131.100 1.7944916
75 598.799 1.7803651
23 13.200 1.7670597
29 8.800 1.5769908
4 14.601 1.5523531
80 622.002 1.5216110
16 62.300 1.4101418
15 23.802 1.3618003
43 32.700 1.3186736
37 10.603 1.2963410
42 158.202 1.2701575
74 11.955 1.2261321
14 41.101 1.1882761
53 51.761 1.1869709
22 634.302 1.1610340
31 176.905 1.1545129
40 337.302 1.1423660
67 353.800 1.0677547
48 541.401 1.0600000
78 214.199 1.0041912
41 20.701 0.8077747
46 79.800 0.7580237
58 164.899 0.7242237
20 38.401 0.6711930
64 615.801 0.6390618
10 5.902 0.6296825
26 8.200 0.6251400
61 5.600 0.6224147
47 12.800 0.5614268
34 410.002 0.5000000
57 6.101 0.4801042
1 5.201 0.4178516
27 12.002 0.4080441
21 27.001 0.3324154
51 17.601 0.2549510
17 103.602 0.2529822
56 24.702 0.2121320
18 7.400 0.1886796
69 16.301 0.1204159
39 349.001 0.1170470
30 23.000 0.1104536
68 860.301 0.0984886
59 63.500 0.0806226
19 6.001 0.0632456

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

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

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

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

other attached packages:
 [1] scales_1.1.1     DT_0.20          readxl_1.3.1     lubridate_1.8.0 
 [5] dplyr_1.0.7      nnet_7.3-16      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.1  xfun_0.28         purrr_0.3.4      
 [5] colorspace_2.0-2  vctrs_0.3.8       generics_0.1.1    viridisLite_0.4.0
 [9] htmltools_0.5.2   yaml_2.2.1        utf8_1.2.2        rlang_0.4.12     
[13] jquerylib_0.1.4   later_1.3.0       pillar_1.6.4      glue_1.5.0       
[17] withr_2.4.2       tweenr_1.0.2      lifecycle_1.0.1   stringr_1.4.0    
[21] cellranger_1.1.0  munsell_0.5.0     gtable_0.3.0      rvest_1.0.2      
[25] htmlwidgets_1.5.4 evaluate_0.14     knitr_1.36        fastmap_1.1.0    
[29] httpuv_1.6.3      fansi_0.5.0       highr_0.9         Rcpp_1.0.7       
[33] promises_1.2.0.1  webshot_0.5.2     systemfonts_1.0.3 farver_2.1.0     
[37] fs_1.5.0          hms_1.1.1         digest_0.6.28     stringi_1.7.5    
[41] grid_4.1.2        rprojroot_2.0.2   tools_4.1.2       magrittr_2.0.1   
[45] tibble_3.1.6      crayon_1.4.2      whisker_0.4       pkgconfig_2.0.3  
[49] ellipsis_0.3.2    xml2_1.3.2        prettyunits_1.1.1 svglite_2.0.0    
[53] httr_1.4.2        rmarkdown_2.11    rstudioapi_0.13   R6_2.5.1         
[57] git2r_0.28.0      compiler_4.1.2