Rinaldini registered the tree rings measurements as groups of lines, one line per section, one group for tree. Measurements are progressive, from bark (or underbark if missing), coded by modifying character format (bold for bark, red for the two measurements with pith -not measured- in between) Having used format attributes to code info, direct data extraction (say via CSV) is not viable since formatting would be lost. Google scripts have been developed in order to transfer original information in explicit tables: one listing sections data (section distance from tree base: s_height), the other with one line for each measurement, explicitly connecting it with: TreeId, row (hence section), col (hence year of growth), is-bold and is-red. Such raw tables have to be further processed to:
* directly connect to a meaningful SectionId
* distinguish measurements before and after pith
* explicitly connect each measurements with ‘year of growth’
* set bark apart
* compute ring widths

Connect to GS

(https://cran.r-project.org/web/packages/googlesheets/vignettes/basic-usage.html)

library(googlesheets)
suppressMessages(library(dplyr))
gsn <- "RotelleVer2"
gsurl <- "https://docs.google.com/spreadsheets/d/15ZLnI780oKr4QKuc4k4UAwZ6w6YmEE8tj4c2sU44xLQ/edit#gid=1996889235"
gs_ls(gsn)
## # A tibble: 1 × 10
##   sheet_title author  perm version             updated
##         <chr>  <chr> <chr>   <chr>              <dttm>
## 1 RotelleVer2 scotti    rw     old 2017-08-06 18:19:13
## # ... with 5 more variables: sheet_key <chr>, ws_feed <chr>,
## #   alternate <chr>, self <chr>, alt_key <chr>
Rv2 <- gs_url(gsurl)
Sects0 <- Rv2 %>%  gs_read(ws = "Sections", progress=F)
Diams0 <- Rv2 %>%  gs_read(ws = "Diameters", progress=F)

Verify basic characteristics

  1. Are the mesurements, within each section, progressive?
    (Non progressive measurements within each section are evidenced in the Google script pahase, and should already have been corrected before this pahase)
  2. Each section has exactly two consecutive ‘red’ measurements?
  3. All sections (‘row’) in Diams_at are present in Sects_at table?
library(sqldf, quietly=F)
Sects_at <- Sects0
Diams_at <- Diams0
cat(paste("A) n. of non-progressive measures:",nrow(sqldf("
  select A.TreeId, A.row, A.col, B.col, A.value, B.Value, B.value - A.Value inc0 from Diams_at A join Diams_at B on A.TreeId = B.TreeId and A.row = B.row and A.col +1 = B.col where inc0<=0 "))))
## A) n. of non-progressive measures: 0
cat(paste("B1) n. of sections without a 'red' couple:", nrow(sqldf("
  select TreeId, row, count(*) n_red from (select * from Diams_at where red) group by TreeId, row having n_red <> 2    "))))
## B1) n. of sections without a 'red' couple: 0
cat(paste("B2) n. of not consecutive 'red' couples:", nrow(sqldf("
  select TreeId, row, min(col) a_max, max(col) b_min, max(col)-min(col) d from (select * from Diams_at A where red) group by TreeId, row having d <> 1"))))
## B2) n. of not consecutive 'red' couples: 0
cat(paste("C) n. of 'sections Id' in Diam missing in Sects_at table:", nrow(sqldf("
  select * from (select distinct row from Diams_at) left natural join Sects_at where TreeId is NULL or s_height is NULL  "))))
## C) n. of 'sections Id' in Diam missing in Sects_at table: 0

Complete tables for sections and diameters

source('FromGS2at.R')

Verify measurements internal coherence

## A) section above has more rings than the one below 
##    n. of non compatible couples of sections: 3
##   TreeId SectId nam SectId nam diff
## 1     32      2  30      3  31   -1
## 2     32      5  25      6  26   -1
## 3     33      4  31      5  32   -1
## B0) WARNING: if 'TRUE' successive tests are unreliable: FALSE
## B1)  n. of 'implicitly complete sections (i.e. 'side b' has no bark but also no 'comment'): 9
## B2)  n. of 'complete' sections: 157  - out of: 189
## B3)  List of sections signalled as NOT 'complete' (i.e. with 'comment) that actually seem complete:
##   TreeId SectId abark nam nbm bbark nm comment complete max_b_year
## 1     14      1     1  48  49     0 98   rotta    FALSE       2017
## C1)  n. of 'complete' with matching sides: 17
## C2)  n. of 'complete' with NON matching sides: 140