Last updated: 2022-03-15

Checks: 7 0

Knit directory: Test/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). 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 3004eb2. 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/Stabiliseur/
    Ignored:    data/json/
    Ignored:    data/plan/
    Ignored:    fig/
    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/antoine_20220305.Rmd) and HTML (docs/antoine_20220305.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 3004eb2 cfcforever 2022-03-15 add new content
html 6ae285a cfcforever 2022-03-15 Build site.
Rmd 981e139 cfcforever 2022-03-15 add new content
html c03bb38 cfcforever 2022-03-15 Build site.
Rmd 19b97b1 cfcforever 2022-03-15 add new content
html 47c9dcd cfcforever 2022-03-15 Build site.
Rmd a4cbda8 cfcforever 2022-03-15 add new content
html c350877 cfcforever 2022-03-15 Build site.
Rmd 2480360 cfcforever 2022-03-15 add new content
html 7bf017e cfcforever 2022-03-15 Build site.
Rmd 1d1f0b6 cfcforever 2022-03-15 add new content
html 1487b20 cfcforever 2022-03-15 Build site.
Rmd ac15b7d cfcforever 2022-03-15 add new content
html 2fb389f cfcforever 2022-03-15 Build site.
Rmd 9f94a71 cfcforever 2022-03-15 add new content
html 8dc1ef8 cfcforever 2022-03-15 Build site.
Rmd ff11b9e cfcforever 2022-03-15 add new content
html ed258bd cfcforever 2022-03-15 Build site.
Rmd ef60904 cfcforever 2022-03-15 add new content
html e553be9 cfcforever 2022-03-15 Build site.
Rmd 0ce3d8f cfcforever 2022-03-15 add new content
html fd097f4 cfcforever 2022-03-15 Build site.
Rmd 25ede7e cfcforever 2022-03-15 add new content
html 087d762 cfcforever 2022-03-14 Build site.
Rmd 16cf544 cfcforever 2022-03-14 add new content
html 29ba1af cfcforever 2022-03-14 Build site.
Rmd a7b2ad5 cfcforever 2022-03-14 add new content
html a979f55 cfcforever 2022-03-14 Build site.
Rmd fbddda5 cfcforever 2022-03-14 add new content
html d973193 cfcforever 2022-03-14 Build site.
Rmd ebe3469 cfcforever 2022-03-14 add new content
html 70c0d6d cfcforever 2022-03-14 Build site.
Rmd be1cacc cfcforever 2022-03-14 add new content
html 2cc666b cfcforever 2022-03-11 Build site.
Rmd 8916481 cfcforever 2022-03-11 add new content
html 7b2072e cfcforever 2022-03-10 Build site.
Rmd ee74b67 cfcforever 2022-03-10 add new content

2022-03-05

json_data = fromJSON(file = paste0("data/json/2022-03-05/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 %>% filter(tag %in% c("4288","295e"))
dat = dat[order(dat$record_timestamp),]
dat = cbind.data.frame(dat, convert_date(dat$record_timestamp))
dat$date = as.character(dat$date)
dat$x = as.numeric(dat$x)
dat$y = as.numeric(dat$y)

list_tag <- split(dat, dat$tag)

data1 = list_tag[[1]]
data1$diff_ts = round(c(0, data1$record_timestamp[-1]-data1$record_timestamp[-nrow(data1)]), 3)
data1 = data1[-which(data1$diff_ts<=0.1),]
data1$x = data1$x/100
data1$y = data1$y/100
data1$diff_dist = NA
for (k in 2:nrow(data1)){
  data1$diff_dist[k] = round(as.numeric(dist(data1[(k-1):k,c("x","y")])), 3)
}

data2 = list_tag[[2]]
data2$diff_ts = round(c(0, data2$record_timestamp[-1]-data2$record_timestamp[-nrow(data2)]), 3)
data2 = data2[-which(data2$diff_ts<=0.1),]
data2$x = data2$x/100
data2$y = data2$y/100
data2$diff_dist = NA
for (k in 2:nrow(data2)){
  data2$diff_dist[k] = round(as.numeric(dist(data2[(k-1):k,c("x","y")])), 3)
}

data = rbind.data.frame(data1, data2)
data = data[order(data$record_timestamp),]
output_table = data.frame(tag = unique(data$tag))
output_table$count = c(nrow(data1), nrow(data2))
output_table$count_NA = c(sum(is.na(data1$x)), sum(is.na(data2$x)))
output_table$NA_ratio = round(output_table$count_NA/output_table$count,2)
output_table$time_start = c(as.character(head(data1$date,1)), as.character(head(data2$date,1)))
output_table$time_end = c(as.character(tail(data1$date,1)), as.character(tail(data2$date,1)))

datatable(output_table)

hourly plot

tags = unique(data$tag)
tags = names_tag %>% filter(Identifiant %in% tags)

data$H = factor(as.numeric(data$H), levels = c(0:23))

q = p + theme_bw() +
  geom_point(data = data, aes(x=x, y=y, col=tag), na.rm = T) +
  coord_equal(ratio = 1, xlim = c(-20,17), ylim = c(-35,35)) +
  labs(x = "", y = "") + 
  facet_wrap(~H, nrow = 4, drop = F)
print(q)

Version Author Date
2fb389f cfcforever 2022-03-15
# ggsave(filename = "fig/20220217_Antoine_hourly_plot.png", width=18, height=18)

discontinued situations

data2 = data2 %>%
  filter(record_timestamp <= max(data1$record_timestamp)) %>%
  filter(record_timestamp >= min(data1$record_timestamp))

nt = sum(data2$diff_dist>=5, na.rm = T)
for (k in 1:nt){
  cat("\n")
  cat("## ", "case", k, "\n")
  t2 = order(data2$diff_dist, decreasing = T)[k]
  t1 = t2-1
  dat2 = data2[(t2-1):(t2),]

  dat1 = data1 %>%
    filter(record_timestamp>=min(dat2$record_timestamp)) %>%
    filter(record_timestamp<=max(dat2$record_timestamp))
  
  dat = data %>%
    filter(record_timestamp>=min(dat2$record_timestamp)) %>%
    filter(record_timestamp<=max(dat2$record_timestamp))
  print(tagList(datatable(dat[,c("tag","x","y","record_timestamp","date","diff_ts","diff_dist")])))
  
  if (nrow(dat1)==0){
    cat("> no data for Testeur!!!", "\n")
  }else{
    q <- p + theme_bw() +
      geom_point(data = dat1, aes(x=x, y=y, col="Testeur"), na.rm = T) +
      geom_point(data = data2[(t2-1),], aes(x=x, y=y, col="Antoine before"), na.rm = T) +
      geom_point(data = data2[(t2),], aes(x=x, y=y, col="Antoine after"), na.rm = T) +
      scale_color_manual(values = c("green", "blue", "red")) +
      coord_equal(ratio = 1, xlim = c(-20,17), ylim = c(-35,35)) +
      theme(legend.title = element_blank()) +
      labs(x = "", y = "", title = head(dat2$date,1), subtitle = tail(dat2$date,1))
    print(q)
  }
  
  cat("\n")
}

case 1

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15
8dc1ef8 cfcforever 2022-03-15
fd097f4 cfcforever 2022-03-15
2cc666b cfcforever 2022-03-11
7b2072e cfcforever 2022-03-10

case 2

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 3

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 4

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 5

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 6

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 7

no data for Testeur!!!

case 8

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 9

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 10

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 11

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 12

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 13

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 14

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 15

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

case 16

Version Author Date
c03bb38 cfcforever 2022-03-15
c350877 cfcforever 2022-03-15
1487b20 cfcforever 2022-03-15

loss-ratio

data2_loss = data2[which(data2$diff_dist>=5),]
datatable(data2_loss)
nr_loss = round(sum(data2_loss$diff_ts)/0.2, 0)

cat("> maximum loss ratio:", round(nr_loss/(nr_loss+nrow(data2))*100,2), "%", "\n")

maximum loss ratio: 18.23 %


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] htmltools_0.5.2  openxlsx_4.2.4   scales_1.1.1     DT_0.19         
 [5] readxl_1.3.1     lubridate_1.7.10 dplyr_1.0.5      nnet_7.3-15     
 [9] kableExtra_1.3.4 rjson_0.2.20     cowplot_1.1.1    gifski_1.4.3-1  
[13] gganimate_1.0.7  ggplot2_3.3.5    workflowr_1.7.0 

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