-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path101-200.Rmd
56 lines (45 loc) · 1.95 KB
/
101-200.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
```{r, echo=FALSE, purl=FALSE, message=FALSE}
#knitr::opts_chunk$set(results='hide', comment = "#>", purl = FALSE)
library(knitr)
library(kableExtra)
library(stringr)
library(dplyr)
#c_gviz <- read.csv("../../API_tests/catal_sample_1000_GV_output.csv") # read peter's data here
#thumbs <- list.files("thumbs/") # take first 100 > make 10 pages.
#filenames <- str_remove(thumbs, "thumb_")
filenames <- list.files("thumbs/") %>% str_remove("thumb_")
c_gviz_sub <- read.csv("../../API_tests/catal_sample_1000_GV_output.csv") %>%
filter(filename %in% filenames) # read peter's data and keep keep subset of 766 we have thumbnails of
clf <- read.csv("../../API_tests/catal_sample_Clarifi_predictions.csv")
tdf <- clf %>%
rename(score = value, # renaming
value = name,
filename = file_name) %>%
mutate(type = "CP_label", # add type: CP_label
score = round(score, 2)) %>% # reduce to 2 digits
select(type, value, score, filename)
preds <- c_gviz_sub %>%
mutate(type = as.character(type), # renaming
type = ifelse(type == "entity", "GV_entity", (ifelse(type == "label", "GV_label", "GV_ocr")))) %>%
select(type, value, score, filename) %>%
rbind(tdf) # combine CP and GV
```
# Images 101-200
```{r, echo=FALSE, results='asis'}
# create a table with kable and this:
#https://stackoverflow.com/questions/25106481/add-an-image-to-a-table-like-output-in-r
# add image and format using kableExtra:
# https://haozhu233.github.io/kableExtra/awesome_table_in_html.html
for(f in filenames[101:200]){
preds %>%
filter(filename == f) %>% # select one image
# add pointer to thumb
mutate(img = sprintf('![](./thumbs/thumb_%s)', f)) %>%
select(-filename) %>% # remove image name, we'll put it in the caption
# print table
kable(caption = f) %>%
column_spec(4, width = "330px") %>%
collapse_rows(columns = 4, valign = "top") %>%
print() # need to explicitly print from for loop
}
```