-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_table_01_imported_datasets.R
59 lines (44 loc) · 1.67 KB
/
script_table_01_imported_datasets.R
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
56
57
58
59
## Packages
library("tidyverse")
library("qs")
library("xtable")
options(timeout = 1000)
## Data
all.level0 <- "https://storage.googleapis.com/soilspec4gg-public/ossl_all_L0_v1.2.qs"
all.level0 <- qread_url(all.level0)
neospectra <- "https://storage.googleapis.com/soilspec4gg-public/neospectra_nir_v1.2.qs"
neospectra <- qread_url(neospectra)
## Spectral counts
mir.count <- all.level0 %>%
mutate(available_mir = !is.na(scan_mir.1000_abs)) %>%
count(dataset.code_ascii_txt, available_mir) %>%
filter(available_mir) %>%
select(-available_mir) %>%
rename(mir = n)
mir.count
visnir.count <- all.level0 %>%
mutate(available_visnir = !is.na(scan_visnir.1000_ref)) %>%
count(dataset.code_ascii_txt, available_visnir) %>%
filter(available_visnir) %>%
select(-available_visnir) %>%
rename(visnir = n)
visnir.count
neospectra.count <- neospectra %>%
group_by(id.sample_local_c) %>%
summarise(scan_nir.1500_ref = mean(scan_nir.1500_ref)) %>%
mutate(available_neospectra = !is.na(scan_nir.1500_ref)) %>%
mutate(dataset.code_ascii_txt = "NEOSPECTRA") %>%
count(dataset.code_ascii_txt, available_neospectra) %>%
filter(available_neospectra) %>%
select(-available_neospectra) %>%
rename(nir = n)
neospectra.count
## Final table
final.count <- full_join(visnir.count, mir.count, by = "dataset.code_ascii_txt") %>%
full_join(neospectra.count, by = "dataset.code_ascii_txt")
final.count <- final.count %>%
mutate(dataset.code_ascii_txt = gsub("\\.SSL", "", dataset.code_ascii_txt)) %>%
mutate(dataset.code_ascii_txt = gsub("\\.", "-", dataset.code_ascii_txt))
final.count
write_csv(final.count, "outputs/table1_source_and_spectra_count.csv")
print(xtable(final.count))