Last updated: 2021-09-28

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 8f06f2c. 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:    .Rproj.user/
    Ignored:    code/fun_convert_date.R
    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/09-26.Rmd) and HTML (docs/09-26.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 f8288b3 cfcforever 2021-09-28 Build site.
html 2846b2e cfcforever 2021-09-28 Build site.
html 08db2ac cfcforever 2021-09-27 Build site.
Rmd 5ff2790 cfcforever 2021-09-27 some changes
html 180545c cfcforever 2021-09-27 Build site.
Rmd a78cc3d cfcforever 2021-09-27 make changes

load data.json

today = "2021-09-26"
cat("data on:", today, "\n")
data on: 2021-09-26 
json_data = fromJSON(file = paste0("data/json/", today, "/position.json"))
cat("Total collected positions: ", length(json_data), "\n")
Total collected positions:  413097 
tagId_seq = unlist(lapply(json_data, function(x){x["tag_id"][[1]]}))
tagId = unique(tagId_seq)
nb_tag = length(tagId)

cat("Tags are: ", tagId, "\n")
Tags are:  0db4 2f77 2b9c 19ab 2c57 2f40 0da6 0baf 0d82 2e5b 2c5d 2a51 2f7b 2e55 28d2 2e8d 
table(tagId_seq)
tagId_seq
  0baf   0d82   0da6   0db4   19ab   28d2   2a51   2b9c   2c57   2c5d   2e55 
   458    606    516 122774  25961    508    567 129721    958    338    448 
  2e5b   2e8d   2f40   2f77   2f7b 
   429    325    503 128505    480 

general analysis

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)
dat$y = as.numeric(dat$y)

list_tag <- split(dat, dat$tag)

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 = F)
tag first_record last_record number number_NA ratio_non_NA freq_1Q freq_median freq_3Q
0db4 2021-09-26 00:00:00 2021-09-26 07:26:57 122774 34891 0.72 0.197 0.200 0.202
2f77 2021-09-26 00:00:00 2021-09-26 07:25:20 128505 6729 0.95 0.198 0.200 0.202
2b9c 2021-09-26 00:00:00 2021-09-26 07:24:37 129721 154 1.00 0.199 0.200 0.201
19ab 2021-09-26 00:00:00 2021-09-26 07:22:25 25961 231 0.99 0.997 1.000 1.003
2c57 2021-09-26 00:00:44 2021-09-26 07:13:07 958 83 0.91 0.198 0.252 59.999
2f40 2021-09-26 00:00:02 2021-09-26 07:12:49 503 4 0.99 59.953 59.999 60.002
0da6 2021-09-26 00:00:42 2021-09-26 07:12:47 516 19 0.96 59.950 59.998 60.002
0baf 2021-09-26 00:00:22 2021-09-26 07:12:43 458 1 1.00 59.996 60.000 60.002
0d82 2021-09-26 00:01:33 2021-09-26 07:12:43 606 8 0.99 0.251 59.986 60.002
2e5b 2021-09-26 00:00:07 2021-09-26 07:12:17 429 226 0.47 59.996 60.000 60.004
2c5d 2021-09-26 00:00:27 2021-09-26 07:12:14 338 336 0.01 59.997 60.001 60.049
2a51 2021-09-26 00:00:13 2021-09-26 07:12:12 567 3 0.99 59.752 59.998 60.003
2f7b 2021-09-26 00:00:01 2021-09-26 07:12:04 480 21 0.96 59.950 59.999 60.008
2e55 2021-09-26 00:00:13 2021-09-26 07:12:02 448 4 0.99 59.951 60.000 60.047
28d2 2021-09-26 00:00:41 2021-09-26 07:12:01 508 25 0.95 59.949 59.999 60.003
2e8d 2021-09-26 01:41:36 2021-09-26 06:41:38 325 7 0.98 0.197 0.202 0.298
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 
cat("number of invalid positions:", length(x_na), "/", length(tagId_seq), "(=", 
    length(x_na)/length(tagId_seq)*100, "%)", "\n")
number of invalid positions: 42742 / 413097 (= 10.34672 %) 
if (length(x_na)!=0){
  dat = dat[-x_na,]
}
list_tag <- split(dat, dat$tag)

for (tag in names(list_tag)){
  if (!is.null(list_tag[tag][[1]])){
    dd = list_tag[tag][[1]]
    dd[,c("x","y")] = dd[,c("x","y")]/100
    rownames(dd) = 1:nrow(dd)
    dd$num = 1:nrow(dd)
    dd$timediff = c(0, dd$record_timestamp[-1] - dd$record_timestamp[-nrow(dd)])
    
    list_tag[tag][[1]] = dd
  }
}

dat = do.call(rbind.data.frame, list_tag)

plot

for (tag in names(list_tag)){
  dd = list_tag[tag][[1]]
  
  p <- ggplot(dd) + theme_bw() +
    geom_point(aes(x=x,y=y)) +
    coord_equal(ratio = 1, xlim = c(-30,5), ylim = c(-60,5)) +
    labs(title = tag)
  print(p)
}

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

Version Author Date
f8288b3 cfcforever 2021-09-28
2846b2e cfcforever 2021-09-28
08db2ac cfcforever 2021-09-27
180545c cfcforever 2021-09-27

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

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] lubridate_1.7.10 dplyr_1.0.6      nnet_7.3-14      kableExtra_1.1.0
[5] rjson_0.2.20     cowplot_1.1.0    gganimate_1.0.7  ggplot2_3.3.3   
[9] 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] munsell_0.5.0     gtable_0.3.0      rvest_1.0.0       evaluate_0.14    
[25] labeling_0.3      knitr_1.33        httpuv_1.5.4      fansi_0.4.1      
[29] gifski_0.8.6      highr_0.8         Rcpp_1.0.5        readr_1.4.0      
[33] promises_1.1.1    scales_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