Last updated: 2021-10-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 5529d94. 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/figure/
    Ignored:    data/.DS_Store
    Ignored:    data/Stabiliseur/
    Ignored:    data/json/
    Ignored:    data/plan/
    Ignored:    fig/
    Ignored:    workflowr.R

Untracked files:
    Untracked:  analysis/2021-10-12b.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/2021-10-10-2000-2100.Rmd) and HTML (docs/2021-10-10-2000-2100.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 5529d94 cfcforever 2021-10-15 add new analysis

data from Compass

today = "2021-10-10"
cat("data on:", today, "\n")
data on: 2021-10-10 
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[which(dat$record_timestamp>=1633888800 & dat$record_timestamp<=1633892400),]
cat("Total collected positions: ", nrow(dat), "\n")
Total collected positions:  76462 
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

tagId = unique(dat$tag)

names_tag <- read.table(file = "data/tag_names_20210924.txt", header = T, sep = "\t")
names_tag = names_tag[names_tag$id%in%tagId, ]

tagId = names_tag$id
nb_tag = length(tagId)

dat = dat[dat$tag%in%tagId,]
dat$label = factor(dat$tag, levels = names_tag$id, labels = names_tag$label)
dat$tagn = as.numeric(factor(dat$tag, levels = names_tag$id, labels = 1:nb_tag))

list_tag <- split(dat, dat$tag)

quality of collecting data

table_tag <- data.frame(tag = names_tag$id, label = names_tag$label)
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 label first_record last_record number number_NA ratio_non_NA
2a51 BLA 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 2 1.00
0da6 BRA1 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 0 1.00
2f7b BRA2 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 15 1.00
2f40 BRA4 2021-10-10 20:00:00 2021-10-10 20:59:59 7165 29 1.00
2f77 BRP1 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 86 0.99
2b9c BRP2 2021-10-10 20:00:00 2021-10-10 20:59:59 6981 7 1.00
2c57 DYN1 2021-10-10 20:00:00 2021-10-10 20:59:59 7188 1973 0.73
2e8d DYN3 2021-10-10 20:16:32 2021-10-10 20:59:59 3465 13 1.00
0baf ELC 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 59 0.99
19ab FIX 2021-10-10 20:00:01 2021-10-10 20:59:59 1464 7 1.00
28d2 ORD 2021-10-10 20:00:00 2021-10-10 20:59:59 7215 298 0.96
2e55 SCO 2021-10-10 20:00:00 2021-10-10 20:59:59 7164 105 0.99
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)
}
table_diff_ts = cbind.data.frame(label = names_tag$label, table_diff_ts)

kable(table_diff_ts) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
label 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
2a51 BLA 0.135 0.337 0.408 0.434 0.471 0.506 0.525 0.565 0.607 0.660 1.120
0da6 BRA1 0.137 0.367 0.415 0.455 0.472 0.505 0.522 0.558 0.595 0.653 1.030
2f7b BRA2 0.362 0.440 0.462 0.472 0.482 0.505 0.515 0.521 0.534 0.567 0.913
2f40 BRA4 0.138 0.372 0.418 0.457 0.473 0.505 0.521 0.557 0.588 0.626 1.028
2f77 BRP1 0.136 0.389 0.446 0.466 0.479 0.506 0.518 0.531 0.564 0.611 0.978
2b9c BRP2 0.044 0.455 0.464 0.473 0.481 0.505 0.515 0.522 0.547 0.568 61.003
2c57 DYN1 0.044 0.379 0.426 0.462 0.476 0.505 0.519 0.543 0.568 0.618 0.991
2e8d DYN3 0.135 0.459 0.477 0.506 0.515 0.522 0.536 0.560 0.571 0.609 776.683
0baf ELC 0.180 0.368 0.418 0.458 0.473 0.505 0.520 0.553 0.579 0.648 0.938
19ab FIX 0.045 2.266 2.343 2.396 2.450 2.498 2.569 2.616 2.662 2.726 3.439
28d2 ORD 0.044 0.379 0.426 0.460 0.472 0.495 0.516 0.536 0.568 0.616 14.227
2e55 SCO 0.135 0.322 0.389 0.436 0.472 0.506 0.523 0.564 0.610 0.691 1.065

plot

plan <- read_excel("data/plan/Wall_lignes_firminy.xlsx")
plan = as.data.frame(plan)
plan$`Start X` <- as.numeric(plan$`Start X`)/100
plan$`Start Y` <- as.numeric(plan$`Start Y`)/100
plan$`End X` <- as.numeric(plan$`End X`)/100
plan$`End Y` <- as.numeric(plan$`End Y`)/100
colnames(plan) = c("Name", "Length", "Linetype Scale", "Angle", "Delta X",
                   "Delta Y", "Delta Z", "EndX", "EndY", "EndZ", 
                   "StartX", "StartY", "StartZ")
p <- ggplot(plan) + theme_bw() + 
  geom_segment(aes(x=StartX, y=StartY, xend=EndX, yend=EndY))
for (k in 1:nb_tag){
  tag = names_tag$id[k]
  label = names_tag$label[k]
  cat("\n")
  cat("### ", label, "\n")
  dd = list_tag[tag][[1]]
  if (!is.null(dd)){
    q <- p + 
      geom_point(data = dd, aes(x=x,y=y), col="red", size = 1) +
      coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-60,5)) + 
      labs(x = "", y = "", title = paste0(tag, " - ", names_tag$Matériel[names_tag$id==tag]))
    print(q)
  }else{
    cat("NO DATA for plot!!")
  }
  cat("\n")
}

BLA

Warning: Removed 2 rows containing missing values (geom_point).

BRA1

BRA2

Warning: Removed 15 rows containing missing values (geom_point).

BRA4

Warning: Removed 29 rows containing missing values (geom_point).

BRP1

Warning: Removed 86 rows containing missing values (geom_point).

BRP2

Warning: Removed 7 rows containing missing values (geom_point).

DYN1

Warning: Removed 1973 rows containing missing values (geom_point).

DYN3

Warning: Removed 13 rows containing missing values (geom_point).

ELC

Warning: Removed 59 rows containing missing values (geom_point).

FIX

Warning: Removed 7 rows containing missing values (geom_point).

ORD

Warning: Removed 298 rows containing missing values (geom_point).

SCO

Warning: Removed 105 rows containing missing values (geom_point).

data from serveur

rm(list = ls())
source("code/fun_convert_date.R")

today = "2021-10-10"
cat("data on:", today, "\n")
data on: 2021-10-10 
json_data = fromJSON(file = paste0("data/json/", today, "/20211010_2000_2100.json"))
dat <- data.frame(tag = unlist(lapply(json_data, function(x){x["tag_id"][[1]]})),
                  x = rep(NA, length(json_data)),
                  y = rep(NA, length(json_data)),
                  record_timestamp = as.numeric(unlist(lapply(json_data, function(x){x["record_timestamp"][[1]]}))))
dat$x[unlist(lapply(json_data, function(x){length(unlist(x))==9}))] = unlist(lapply(json_data, function(x){x["x"][[1]]}))
dat$y[unlist(lapply(json_data, function(x){length(unlist(x))==9}))] = unlist(lapply(json_data, function(x){x["y"][[1]]}))

range(dat$record_timestamp)
[1] 1633888800 1633892400
cat("Total collected positions: ", nrow(dat), "\n")
Total collected positions:  155717 
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

tagId = unique(dat$tag)

names_tag <- read.table(file = "data/tag_names_20210924.txt", header = T, sep = "\t")
names_tag = names_tag[names_tag$id%in%tagId, ]

tagId = names_tag$id
nb_tag = length(tagId)

dat = dat[dat$tag%in%tagId,]
dat$label = factor(dat$tag, levels = names_tag$id, labels = names_tag$label)
dat$tagn = as.numeric(factor(dat$tag, levels = names_tag$id, labels = 1:nb_tag))

list_tag <- split(dat, dat$tag)

quality of collecting data

table_tag <- data.frame(tag = names_tag$id, label = names_tag$label)
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 label first_record last_record number number_NA ratio_non_NA
2a51 BLA 2021-10-10 20:00:00 2021-10-10 20:59:59 17313 17313 0
0da6 BRA1 2021-10-10 20:00:00 2021-10-10 20:59:59 17018 17018 0
2f7b BRA2 2021-10-10 20:00:00 2021-10-10 20:59:59 17310 17310 0
2f40 BRA4 2021-10-10 20:00:00 2021-10-10 20:59:59 17311 17311 0
2b9c BRP2 2021-10-10 20:00:00 2021-10-10 20:59:59 11548 11548 0
2c57 DYN1 2021-10-10 20:00:00 2021-10-10 20:59:59 17311 17311 0
2e8d DYN3 2021-10-10 20:21:41 2021-10-10 20:54:54 2794 2794 0
0baf ELC 2021-10-10 20:00:00 2021-10-10 20:59:59 17039 17039 0
19ab FIX 2021-10-10 20:00:00 2021-10-10 20:59:59 3495 3495 0
28d2 ORD 2021-10-10 20:00:00 2021-10-10 20:59:59 17318 17318 0
2e55 SCO 2021-10-10 20:00:00 2021-10-10 20:59:59 17260 17260 0
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)
}
table_diff_ts = cbind.data.frame(label = names_tag$label, table_diff_ts)

kable(table_diff_ts) %>%
  kable_styling(bootstrap_options = "striped", full_width = T)
label 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
2a51 BLA 0.150 0.195 0.197 0.199 0.200 0.2 0.200 0.201 0.203 0.205 71.370
0da6 BRA1 0.151 0.196 0.198 0.199 0.200 0.2 0.200 0.201 0.202 0.204 77.167
2f7b BRA2 0.155 0.196 0.198 0.199 0.200 0.2 0.200 0.201 0.202 0.204 124.363
2f40 BRA4 0.148 0.196 0.197 0.198 0.200 0.2 0.200 0.202 0.203 0.204 71.423
2b9c BRP2 0.006 0.196 0.198 0.198 0.200 0.2 0.200 0.201 0.202 0.204 1122.400
2c57 DYN1 0.148 0.196 0.197 0.198 0.200 0.2 0.200 0.202 0.203 0.204 77.071
2e8d DYN3 0.155 0.196 0.198 0.198 0.200 0.2 0.200 0.202 0.202 0.204 857.107
0baf ELC 0.005 0.196 0.198 0.199 0.200 0.2 0.200 0.201 0.202 0.204 77.262
19ab FIX 0.001 0.994 0.997 0.998 1.000 1.0 1.000 1.001 1.002 1.004 199.064
28d2 ORD 0.142 0.195 0.197 0.198 0.199 0.2 0.201 0.202 0.203 0.205 71.674
2e55 SCO 0.146 0.194 0.197 0.198 0.199 0.2 0.201 0.202 0.203 0.206 76.918

plot

plan <- read_excel("data/plan/Wall_lignes_firminy.xlsx")
plan = as.data.frame(plan)
plan$`Start X` <- as.numeric(plan$`Start X`)/100
plan$`Start Y` <- as.numeric(plan$`Start Y`)/100
plan$`End X` <- as.numeric(plan$`End X`)/100
plan$`End Y` <- as.numeric(plan$`End Y`)/100
colnames(plan) = c("Name", "Length", "Linetype Scale", "Angle", "Delta X",
                   "Delta Y", "Delta Z", "EndX", "EndY", "EndZ", 
                   "StartX", "StartY", "StartZ")
p <- ggplot(plan) + theme_bw() + 
  geom_segment(aes(x=StartX, y=StartY, xend=EndX, yend=EndY))
for (k in 1:nb_tag){
  tag = names_tag$id[k]
  label = names_tag$label[k]
  cat("\n")
  cat("### ", label, "\n")
  dd = list_tag[tag][[1]]
  if (!is.null(dd)){
    q <- p + 
      geom_point(data = dd, aes(x=x,y=y), col="red", size = 1) +
      coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-60,5)) + 
      labs(x = "", y = "", title = paste0(tag, " - ", names_tag$Matériel[names_tag$id==tag]))
    print(q)
  }else{
    cat("NO DATA for plot!!")
  }
  cat("\n")
}

BLA

Warning: Removed 17313 rows containing missing values (geom_point).

BRA1

Warning: Removed 17018 rows containing missing values (geom_point).

BRA2

Warning: Removed 17310 rows containing missing values (geom_point).

BRA4

Warning: Removed 17311 rows containing missing values (geom_point).

BRP2

Warning: Removed 11548 rows containing missing values (geom_point).

DYN1

Warning: Removed 17311 rows containing missing values (geom_point).

DYN3

Warning: Removed 2794 rows containing missing values (geom_point).

ELC

Warning: Removed 17039 rows containing missing values (geom_point).

FIX

Warning: Removed 3495 rows containing missing values (geom_point).

ORD

Warning: Removed 17318 rows containing missing values (geom_point).

SCO

Warning: Removed 17260 rows containing missing values (geom_point).


sessionInfo()
R version 4.0.2 (2020-06-22)
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.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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.17          readxl_1.3.1     lubridate_1.7.10
 [5] dplyr_1.0.6      nnet_7.3-14      kableExtra_1.1.0 rjson_0.2.20    
 [9] cowplot_1.1.0    gifski_0.8.6     gganimate_1.0.7  ggplot2_3.3.3   
[13] workflowr_1.6.2 

loaded via a namespace (and not attached):
 [1] progress_1.2.2    tidyselect_1.1.0  xfun_0.25         purrr_0.3.4      
 [5] colorspace_1.4-1  vctrs_0.3.8       generics_0.1.0    viridisLite_0.3.0
 [9] htmltools_0.5.0   yaml_2.2.1        utf8_1.1.4        rlang_0.4.11     
[13] later_1.1.0.1     pillar_1.6.0      glue_1.4.1        withr_2.4.2      
[17] DBI_1.1.1         tweenr_1.0.1      lifecycle_1.0.0   stringr_1.4.0    
[21] cellranger_1.1.0  munsell_0.5.0     gtable_0.3.0      rvest_1.0.0      
[25] htmlwidgets_1.5.1 evaluate_0.14     labeling_0.3      knitr_1.33       
[29] httpuv_1.5.4      fansi_0.4.1       highr_0.8         Rcpp_1.0.5       
[33] readr_1.4.0       promises_1.1.1    backports_1.1.8   webshot_0.5.2    
[37] farver_2.0.3      fs_1.5.0          hms_1.0.0         digest_0.6.25    
[41] stringi_1.4.6     grid_4.0.2        rprojroot_1.3-2   tools_4.0.2      
[45] magrittr_2.0.1    tibble_3.1.1      crayon_1.4.1      whisker_0.4      
[49] pkgconfig_2.0.3   ellipsis_0.3.1    xml2_1.3.2        prettyunits_1.1.1
[53] httr_1.4.2        rstudioapi_0.13   assertthat_0.2.1  rmarkdown_2.10   
[57] R6_2.4.1          git2r_0.28.0      compiler_4.0.2