A reproducible walkthrough of sewloreSpecimenTables, by Sewlore.
Record a cohort, specimen identifier, cycle number, axis, stage, value and physical unit. Pairing uses cohort, specimen, cycle and axis together. The original unit remains visible after normalization.
library(sewloreSpecimenTables) observations <- synthetic_specimens() print(observations[1:6, ], row.names = FALSE)
## cohort specimen_id wash_cycle axis stage value unit ## SYNTHETIC_A SYN-A-01 1 warp before 20.0 cm ## SYNTHETIC_A SYN-A-01 1 warp after 194.0 mm ## SYNTHETIC_A SYN-A-02 1 warp before 200.0 mm ## SYNTHETIC_A SYN-A-02 1 warp after 19.6 cm ## SYNTHETIC_A SYN-A-01 1 weft before 10.0 cm ## SYNTHETIC_A SYN-A-01 1 weft after 101.0 mm ## provenance value_mm ## SYNTHETIC_NOT_EMPIRICAL 200 ## SYNTHETIC_NOT_EMPIRICAL 194 ## SYNTHETIC_NOT_EMPIRICAL 200 ## SYNTHETIC_NOT_EMPIRICAL 196 ## SYNTHETIC_NOT_EMPIRICAL 100 ## SYNTHETIC_NOT_EMPIRICAL 101
This example treats cycle 2 as incremental: its before value is the measurement before that particular wash. To analyze cumulative change, supply the original baseline explicitly for every cycle. The package never guesses which interpretation you intended.
pairs <- pair_specimen_measurements(observations) print(pairs[, c("cohort", "specimen_id", "wash_cycle", "axis", "before_value", "before_unit", "after_value", "after_unit", "delta_mm", "change_percent")], row.names = FALSE, digits = 4)
## cohort specimen_id wash_cycle axis before_value before_unit after_value ## SYNTHETIC_A SYN-A-01 1 warp 20 cm 194.0 ## SYNTHETIC_A SYN-A-02 1 warp 200 mm 19.6 ## SYNTHETIC_A SYN-A-01 1 weft 10 cm 101.0 ## SYNTHETIC_A SYN-A-02 1 weft 100 mm 100.0 ## SYNTHETIC_A SYN-A-01 2 warp 194 mm 192.0 ## SYNTHETIC_A SYN-A-02 2 warp 196 mm 195.0 ## SYNTHETIC_B SYN-B-01 1 length 4 in 10.0 ## after_unit delta_mm change_percent ## mm -6.0 -3.0000 ## cm -4.0 -2.0000 ## mm 1.0 1.0000 ## mm 0.0 0.0000 ## mm -2.0 -1.0309 ## mm -1.0 -0.5102 ## cm -1.6 -1.5748
Delta is after_mm - before_mm. Change percent divides that delta by the explicitly supplied before value. Contraction gives negative change percent and positive shrinkage percent; expansion reverses those signs.
Cohorts must reflect actual comparability chosen by the operator. A mean across unrelated fabrics or procedures would still be mathematically computable but would lack the intended interpretation. A single complete specimen has no sample standard deviation.
summary_table <- summarise_specimen_pairs(pairs) print(summary_table, row.names = FALSE, digits = 4)
## cohort wash_cycle axis n_paired n_missing mean_before_mm mean_after_mm ## SYNTHETIC_A 1 warp 2 0 200.0 195.0 ## SYNTHETIC_A 1 weft 2 0 100.0 100.5 ## SYNTHETIC_A 2 warp 2 0 195.0 193.5 ## SYNTHETIC_B 1 length 1 0 101.6 100.0 ## mean_change_percent median_change_percent sd_change_percent ## -2.5000 -2.5000 0.7071 ## 0.5000 0.5000 0.7071 ## -0.7706 -0.7706 0.3682 ## -1.5748 -1.5748 NA
The displayed standard deviation is descriptive variation among these synthetic specimen percentages. It is not instrument uncertainty, a confidence interval or evidence of material performance.
incomplete_observations <- observations[-2, ] reported <- pair_specimen_measurements(incomplete_observations, incomplete = "report") print(reported[reported$status != "paired", ], row.names = FALSE)
## cohort specimen_id wash_cycle axis status before_value before_unit ## SYNTHETIC_A SYN-A-01 1 warp missing_after 20 cm ## after_value after_unit before_mm after_mm delta_mm change_percent ## NA <NA> 200 NA NA NA ## shrinkage_percent ## NA
The default pairing mode rejects incomplete pairs. Reporting mode retains a status and leaves computed changes missing. Repeated stages are errors even when their values agree; they are never silently averaged.
write_specimen_pairs(pairs, "my-pairs.csv")
By default, possible spreadsheet formula markers in text cells are prefixed with an apostrophe in the export. Numeric changes keep their signs. This means an affected exported identifier differs from its original; the in-memory object is unchanged. An existing chosen file is overwritten.
Use the fabric measurement methods guide when planning measuring-point labels, baselines and recording precision. This package validates structure and arithmetic; it does not establish a standardized testing protocol or substitute for observing a real specimen.
R uses floating-point arithmetic. Preserve full numeric results for analysis, then round displayed values to match the precision of your measurements. Do not add decimal precision that your recording method did not supply.
MIT licensed. Developed with AI assistance; all source, tests and synthetic fixtures are provided. This self-contained HTML page has no tracking, remote images or external fonts.