CROSS_SECTION

Build a table with one row per observation. Take a snapshot of several series on one date, or read undated observations directly from a CSV file.

Dated series

C=CROSS_SECTION(ALIGNED_COUNTY_LIST,20230101)
Summary=EXTRACT(C,"summary")

Supply an existing aligned series list and a numeric YYYYMMDD date. The operator identifies observations and variables from supported geographic codes or names in the form Variable - Observation. It prefers an exact date. Annual series may match by year.

Undated CSV

Algae=CROSS_SECTION("https://cran.r-universe.dev/ADER/data/algas/csv")
Fra=EXTRACT(Algae,"where:Sp=Fra")
Specimens=EXTRACT(Fra,"data")

The ADER sample contains 359 individual seaweeds. Filtering the species column Sp to Fra selects 77 specimens of Codium fragile. Original row numbers survive filtering, including when specimens have identical measurements. Column names and filter values are case-sensitive.

Extracts

KeyResult
tableLabeled observation table for either input.
dataOriginal columns as a table for CSV input. Numeric matrix for dated series.
matrix, valuesNumeric observations by row. CSV numeric columns retain file order.
where:column=valueFiltered CSV cross section. Apply another extract to the result.
summary, correlationDescriptive statistics or a correlation matrix.
regression, actual_vs_fittedOLS results or observed versus fitted values. The first numeric column is the outcome and subsequent numeric columns are predictors.
residuals, residual_plot, residual_distributionInspect individual errors and their distribution.
slideshowData audit, observations, summary, and applicable analysis panels.

In the algae example the matrix columns are Long (length) and Estado (reproductive status). The default OLS regression therefore treats length as the outcome. Estimating reproductive probability from length requires a binary-response model with Estado as the outcome.

Binary probit, one-way ANOVA and contingency tables

P=EX(Algae,probit)
        A=EX(Algae,"anova:Long:Sp")
        T=EX(Algae,"contingency:Sp:Estado")

Probit uses the logit column-selection rules and the normal CDF. Use probit_model:Y:X1,X2[:group] to choose columns explicitly. ANOVA tests equality of group means assuming independent observations and common within-group variance. The contingency table shows counts, row percentages, margins and the asymptotic Pearson test of independence. Sparse expected counts can make that approximation unreliable. Group tests use complete pairs from the selected CSV rows.

Cross-sectional logit slideshow

Study=EX(Algae,logit)
        BySpecies=EX(Algae,"logit_model:Estado:Long:Sp")

Use logit_model:Y:X1,X2 for multiple numeric predictors. Add :group for separate CSV group fits. Bare logit infers one binary outcome, one predictor, and at most one categorical group. Slides show coefficients and fitted probabilities. With multiple predictors, the chart displays ranked fitted probabilities within groups.

Named-column CSV studies

Sizes=EXTRACT(Algae,"group_summary:Long:Sp")
Reproduction=EXTRACT(Algae,"logit:Estado:Long:Sp")

The grouped summary reports count, mean, sample standard deviation and range. The logit fits a separate intercept and slope for each group and reports the predictor value at a fitted probability of 0.5 when it falls within the observed range. Omit the final group argument for a pooled fit or run it on a filtered cross section. Supply a binary 0/1 outcome and a numeric predictor. Both extracts omit rows missing a required field.

CSV requirements

Use a quoted HTTPS URL serving UTF-8, comma-delimited records with unique, nonempty headers and at least one numeric column. Quoted fields can contain commas, line breaks, and doubled quotation marks. Blank numeric cells, NA, and NaN are treated as missing. Limits are 1 MiB, 20,000 observations by default (excluding the header; override with a positive integer limit in the study JSON or CROSS_SECTION(url,limit)), and 256 columns.

The default allowed host is cran.r-universe.dev. Server administrators can set a comma-separated host list using -Drainbowstats.csv.hosts=host1,host2. Use a direct URL on the default HTTPS port. Redirects are disabled.

Bar charts by observation

Use bar:value:label[:group]. Append | followed by a plain-text caption to place it on the same slide as the bars. Each row retains its own value and groups share the scale.

Elwha=CROSS_SECTION("https://rainbowstats.com/data/elwha_first_detections.csv")
Chart=EX(Elwha,"bar:other_minus_edna_months:species:upstream_of|Positive months mean eDNA was recorded earlier. Negative months mean another survey was earlier. Zero means both reported fish in the same month. For chum above Glines Canyon Dam, only eDNA was reported.")
Observations=EX(Elwha,"table")
Study=SLIDE(Chart,Observations)