Last updated: 2023-03-24

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 5b6db10. 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:    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/signal_quality.Rmd) and HTML (docs/signal_quality.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 8620f4c cfcforever 2021-11-14 Build site.
html f16eab1 cfcforever 2021-10-20 Build site.
html 521a8d5 cfcforever 2021-10-18 Build site.
html cc57acb cfcforever 2021-10-07 Build site.
Rmd 5a89ce8 cfcforever 2021-10-07 add new analysis
html 3778cb3 cfcforever 2021-10-07 Build site.
Rmd 236a786 cfcforever 2021-10-07 add new analysis
html 4bcc428 cfcforever 2021-10-07 Build site.
Rmd 6b3b5d6 cfcforever 2021-10-07 add new analysis
html 0f0ea19 cfcforever 2021-10-07 Build site.
Rmd 601591c cfcforever 2021-10-07 add new analysis
Rmd 12b1fe8 cfcforever 2021-10-07 minor changes

In this page, we will use the heatmap to visualize the signal quality of the disposition.

load data

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

tagId_seq = unlist(lapply(json_data, function(x){x["tag_id"][[1]]}))
tagId = unique(tagId_seq)
nb_tag = length(tagId)

We are using “2021-09-29” data as an example.

data without NAs

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

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)

x_na = which(is.na(dat$x))
y_na = which(is.na(dat$y))
cat("if x_na = y_na:", identical(x_na, y_na), "\n")
if x_na = y_na: TRUE 
if (length(x_na)!=0){
  dat = dat[-x_na,]
}

list_tag <- split(dat, dat$tag)
for (k in 1:nb_tag){
  tag = tagId[k]
  dat_tag <- list_tag[tag][[1]]
  dat_tag$diff_ts = c(dat_tag$record_timestamp[-1]-dat_tag$record_timestamp[-nrow(dat_tag)],0)
  list_tag[tag][[1]] = dat_tag
}

choose a threshold for a minimum interrupted time interval

5s

thres = 5
cat("the threshold is", thres, "seconds.", "\n")
the threshold is 5 seconds. 
dat_lowq = do.call(rbind.data.frame, list_tag)
dat_lowq = dat_lowq %>%
  filter(diff_ts>=thres & tag!="2e8d")

dat_lowq$x = as.numeric(sprintf("%.3f", dat_lowq$x))
dat_lowq$y = as.numeric(sprintf("%.3f", dat_lowq$y))
dat_lowq = dat_lowq[order(dat_lowq$record_timestamp),]

datatable(dat_lowq, rownames = F)

heatmap

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))

1x1

res = 1
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "white", high = "red") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
0f0ea19 cfcforever 2021-10-07
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "red", high = "yellow") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
3778cb3 cfcforever 2021-10-07

2x2

res = 2
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "white", high = "red") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
0f0ea19 cfcforever 2021-10-07
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "red", high = "yellow") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
3778cb3 cfcforever 2021-10-07

10s

thres = 10
cat("the threshold is", thres, "seconds.", "\n")
the threshold is 10 seconds. 
dat_lowq = do.call(rbind.data.frame, list_tag)
dat_lowq = dat_lowq %>%
  filter(diff_ts>=thres & tag!="2e8d")

dat_lowq$x = as.numeric(sprintf("%.3f", dat_lowq$x))
dat_lowq$y = as.numeric(sprintf("%.3f", dat_lowq$y))
dat_lowq = dat_lowq[order(dat_lowq$record_timestamp),]

datatable(dat_lowq, rownames = F)

heatmap

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))

1x1

res = 1
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "white", high = "red") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
4bcc428 cfcforever 2021-10-07

2x2

res = 2
q <- p + 
  geom_bin2d(data = dat_lowq, aes(x = x, y = y), binwidth=c(res,res)) + 
  scale_fill_gradient(low = "white", high = "red") + 
  coord_equal(ratio = 1, xlim = c(-35,5), ylim = c(-65,5)) + 
  labs(x = "", y = "")
print(q)

Version Author Date
8620f4c cfcforever 2021-11-14
521a8d5 cfcforever 2021-10-18
cc57acb cfcforever 2021-10-07
4bcc428 cfcforever 2021-10-07

sessionInfo()
R version 4.2.3 (2023-03-15)
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.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] htmltools_0.5.5  openxlsx_4.2.5.2 scales_1.2.1     DT_0.27         
 [5] readxl_1.4.2     lubridate_1.9.2  dplyr_1.1.1      nnet_7.3-18     
 [9] kableExtra_1.3.4 rjson_0.2.21     cowplot_1.1.1    gifski_1.6.6-1  
[13] gganimate_1.0.8  ggplot2_3.4.1    workflowr_1.7.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       svglite_2.1.1     prettyunits_1.1.1 getPass_0.2-2    
 [5] ps_1.7.3          rprojroot_2.0.3   digest_0.6.31     utf8_1.2.3       
 [9] cellranger_1.1.0  R6_2.5.1          evaluate_0.20     highr_0.10       
[13] httr_1.4.5        pillar_1.9.0      rlang_1.1.0       progress_1.2.2   
[17] rstudioapi_0.14   whisker_0.4.1     callr_3.7.3       jquerylib_0.1.4  
[21] rmarkdown_2.20    labeling_0.4.2    webshot_0.5.4     stringr_1.5.0    
[25] htmlwidgets_1.6.2 munsell_0.5.0     compiler_4.2.3    httpuv_1.6.9     
[29] xfun_0.37         pkgconfig_2.0.3   systemfonts_1.0.4 tidyselect_1.2.0 
[33] tibble_3.2.1      fansi_1.0.4       viridisLite_0.4.1 crayon_1.5.2     
[37] withr_2.5.0       later_1.3.0       grid_4.2.3        jsonlite_1.8.4   
[41] gtable_0.3.3      lifecycle_1.0.3   git2r_0.31.0      magrittr_2.0.3   
[45] zip_2.2.2         cli_3.6.1         stringi_1.7.12    cachem_1.0.7     
[49] farver_2.1.1      fs_1.6.1          promises_1.2.0.1  xml2_1.3.3       
[53] bslib_0.4.2       ellipsis_0.3.2    generics_0.1.3    vctrs_0.6.1      
[57] tools_4.2.3       glue_1.6.2        tweenr_2.0.2      crosstalk_1.2.0  
[61] hms_1.1.3         processx_3.8.0    fastmap_1.1.1     yaml_2.3.7       
[65] timechange_0.2.0  colorspace_2.1-0  rvest_1.0.3       knitr_1.42       
[69] sass_0.4.5