Chapter 8 Exporting Data
Data is easy to export from R
. Tables can be exported by piping to readr::write_csv()
. For diagrams created in ggplot2
, pipe to ggsave()
. Sometimes it is necessary to reduce the resolution of Itrax XRF data, usually to facilitate direct comparison with some other lower resolution data. For example, if calibrating using ICP-MS sub-samples taken at 10 mm intervals, but the Itrax XRF scan is at 0.2 mm, it will be necessary to average 50 Itrax measurements for each ICP-MS measurement. This is facilitated using the itrax_reduce()
function. The example below demonstrates calculating the averages for contiguous 20 mm chunks of the XRF data.
# get the data as 20 mm intervals
itrax_reduce(CD166_19_xrf %>% drop_na(), by = 20) %>%
select(-label) %>%
head()
## # A tibble: 6 × 58
## resample_names depth MSE cps validity Al Si P S Cl Ar
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 9.5 1.50 39598. 1 63.4 337. 0 23.6 1382. 575
## 2 2 29.5 1.65 44454. 1 64.2 272. 0 22.7 1316 627.
## 3 3 49.5 1.67 46676. 1 71.6 288. 0 12.9 1298 669.
## 4 4 69.5 1.70 47447. 1 70.2 317. 0 23.6 1486. 677.
## 5 5 89.5 1.70 47708. 1 73.2 388. 0 23.2 1512. 691.
## 6 6 110. 1.67 47713. 1 83.6 489. 0 23.2 1510. 655
## # ℹ 47 more variables: K <dbl>, Ca <dbl>, Sc <dbl>, Ti <dbl>, V <dbl>,
## # Cr <dbl>, Mn <dbl>, Fe <dbl>, Ni <dbl>, Cu <dbl>, Zn <dbl>, Ga <dbl>,
## # Ge <dbl>, Br <dbl>, Rb <dbl>, Sr <dbl>, Y <dbl>, Zr <dbl>, Pd <dbl>,
## # Cd <dbl>, I <dbl>, Cs <dbl>, Ba <dbl>, Nd <dbl>, Sm <dbl>, Yb <dbl>,
## # Ta <dbl>, W <dbl>, Pb <dbl>, Bi <dbl>, `Mo inc` <dbl>, `Mo coh` <dbl>,
## # filename <dbl>, position <dbl>, `sample surface` <dbl>, `E-gain` <dbl>,
## # `E-offset` <dbl>, `F-slope` <dbl>, `F-offset` <dbl>, `Fe a*2` <dbl>, …