Skip to content

cooccure

0.4.0Package record

Co-Occurrence Network Construction and Manipulation

0packages depend
2.2Kdownloads / year
94.0%test coverage
13/13flavors OK

Overview

About

Constructs co-occurrence networks from several types of input data, such as delimited fields, long/bipartite tables, binary matrices, or wide sequences. Returns tidy edge data frames and supports optional scaling, splitting into several networks, thresholding, and subsetting. Provides eight similarity measures, including Jaccard, cosine, and association strength. Supports export to several network and file formats. Network construction and analysis methods follow Saqr, Lopez-Pernas, Conde, and Hernandez-Garcia (2024, doi:10.1007/978-3-031-54464-4_15).

Changes in 0.4.0
  • cooccurrence() gains a window = parameter for sliding-window co-occurrence on ordered sequence input (lists of vectors and wide TraMineR-style data frames via field = "all"). Each window of w consecutive positions becomes one transaction; states inside the same window co-occur. window = sequence_length reduces to the existing bag-of-states behavior. TraMineR void markers (NA, "", "%", "*", "NaN") are dropped before windowing. Pure base R via embed().
  • cooccurrence() gains aggregate_by = and aggregate = parameters. aggregate_by groups the data by a column (e.g. journal id), computes the per-group co-occurrence network with whatever similarity / counting / scale / window was chosen, then combines the per-group edge weights into ONE final network. aggregate = c("sum", "mean", "min", "max") controls the combiner; count is always summed. Differs from split_by, which keeps groups separate. Cannot be combined with split_by. threshold and top_n apply after aggregation.
Show all changes in 0.4.0Hide the rest of the changes in 0.4.0
  • counting = "attention" adds positional gap-decay weighting: each pair within an ordered transaction contributes exp(-|pos_i - pos_j| / lambda) to the edge. Closer positions give a stronger edge, distant pairs decay. Matches the tna::build_model(type = "attention") semantics, undirected. The new lambda = parameter (default 1.0) controls the decay rate.
  • group = is now accepted as an alias for split_by =.
  • summary.cooccurrence() now returns a structured summary object with network size, density, mean degree, isolates, node-level degree and strength, and optional group-level summaries.
  • print.cooccurrence() now shows a compact diagnostic header before the edge preview, including density, mean degree, isolates, method metadata, and top nodes.
  • plot.cooccurrence(type = "degree") adds a base R degree-distribution plot.
  • cooccurrence() accepts a raw event log directly via action = (the event column), with optional actor =, time =, session =, order =, and time_threshold = (default 900 seconds). The log is sessionized into ordered sequences and each session becomes one transaction, so window = and counting = "attention" apply. Sessionization — timestamp parsing and gap splitting — is delegated to Nestimate::prepare() rather than reimplemented, so Nestimate is required for this input only.
  • cooccurrence() gains vars =, naming the indicator (one-hot) columns directly. The specification is resolved like select in base subset(), so a bare range (vars = A:D), bare names (vars = c(A, B, C)), positions (vars = 2:5), negative selection (vars = -c(id, note)), a logical mask, and a plain character vector all work. Other columns — ids, timestamps, metadata — are ignored, so a one-hot table no longer has to be stripped down to a bare matrix first. Cell values are read as presence, so count tables such as document-term matrices work alongside 0/1 and TRUE/FALSE.
  • Logical (TRUE/FALSE) indicator tables are now auto-detected; previously only numeric 0/1 was recognized.
  • NA in an indicator table is treated as absent. It previously reached Matrix::sparseMatrix() as an NA index and failed with an internal error.
  • cooccurrence() accepts a nestimate_data object from Nestimate::prepare() and uses its sequence_data, so event logs can be sessionized by prepare() (time gaps, timestamp parsing) and networked here without duplicating that logic. Passing one used to fall into the list-of-transactions branch and silently produce items built from the object's internal components.
  • Bug fix: unknown arguments were silently swallowed by ..., so a typo such as simliarity = "jaccard" returned raw counts with no warning. Unknown or unnamed arguments now raise an error.
  • as.data.frame() on a summary.cooccurrence object returns tidy node-level metrics (what = "nodes", the default) or group-level metrics (what = "groups"), so callers no longer reach into the summary object's internals.
  • similarity = "relative" is asymmetric, so each direction is now thresholded on its own value. Filtering by the undirected pair could retain a direction whose weight was below threshold.
  • Added a cross-implementation test suite pinning cooccurrence() to Nestimate::cooccurrence() across all eight similarity measures, all five shared input formats, min_occur, threshold, top_n, their combinations, degenerate inputs, and randomized networks. The two agree exactly once conventions are aligned: Nestimate stores item frequency on the matrix diagonal (diagonal = TRUE) where cooccure zeroes it, and Nestimate keeps every edge tied at the top_n cut where cooccure truncates strictly at N.
  • Bug fix: weight_by combined with min_occur > 1 errored with "'dims' must contain all (i,j) pairs". The binary companion matrix was built from unfiltered column indices against filtered dimensions.
  • Bug fix: min_occur support for weighted input counted rows rather than distinct documents, so duplicate rows for one document could keep an item that appears in only that document.
  • Bug fix: threshold and top_n filtered the edge list but not the stored matrix, so as_matrix(), the heatmap, and the cograph and netobject converters disagreed with the printed edges (top_n = 1 returned one edge but a three-edge matrix). The matrix is now rebuilt from the surviving edges.
  • Bug fix: with counting = "attention", a window covering the whole sequence did not reproduce the unwindowed result. embed() emits each window most-recent-first, and attention reads positional gaps off the transaction, so the decay was mirrored. Windows are restored to reading order before deduplication; set-based counting is unaffected.
  • as_igraph() and as_matrix() now accept output = "gephi" objects, whose columns are named Source/Target/Weight/Count. They previously failed with "undefined columns selected".
  • A group that fails during split_by now warns and names the group. Genuinely edgeless groups are still dropped quietly.
  • threshold = 0 is documented as meaning no filtering rather than "drop negative weights", so centering scalings such as scale = "zscore" keep their negative half.
  • Bug fix: the argument order now reproduces the CRAN 0.1.1 signature for its first thirteen arguments, so positional calls written against 0.1.1 keep their meaning. Arguments added in 0.1.2 (vars, the event-log arguments, group, aggregate_by, aggregate, window, lambda) follow them.
  • Bug fix: a column repeated in vars was counted twice by the sparse builder, inflating weight and count for every pair involving it. Selected columns are now deduplicated.
  • Bug fix: a split_by result inherited the FIRST group's matrix, items, frequencies, and n_transactions attributes from rbind(), so as_matrix() and the other converters silently described only that group. Those attributes are now dropped from split results, and as_matrix() rebuilds from the full edge list. Per-group support is recorded in the new group_items and group_transactions attributes.
  • Bug fix: the groups attribute of a split_by result listed every input level, including groups that produced no edges and were dropped from the data. It now lists only the groups present.
  • Bug fix: per-group density in summary() counted only nodes that appear in an edge, so a group containing an isolated node reported a density above its true value (a group with edge A-B plus isolated C reported density 1 instead of 1/3).
  • Bug fix: summary() and print() reported pooled simple-graph metrics for split_by results, where a node pair can occur once per group. Density could exceed 1 and node degree could exceed n_nodes - 1. density, mean_degree, and possible_edges are now NA for split results, and the per-group table reports the correct values.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 2.9 min · r-release-macos-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK5 OK2026-04-25
Advisories

none known

Documentation

In release 0.4.0
READMEYes · 2,064 wordsVignettesYes · 1 · dynamicNEWSYes · 100% structured · mentions 0.4.0Citation fileNo
Help pages
16
Examples that run
100%15 run in a plain check (1 of them under a condition)
Exported functions with examples
100%
Documented parameters
99%
Return-value docs
100%
Help pages citing references
6%

Downloads

2.2K
CRAN downloads in the past year
Rank #13,869 · ~6/day · ~186/mo
Daily download trend is not available in this view yet.
27230 days
85090 days
2.2K1 year
Compare downloads with other packages →
Also on43 r2u7 autocran

Repository

2Stars
1Forks
0Open issues
0Open PRs
0Releases
84Commits
3Commit identities
84 commits · Last activity 2026-10-08 · 0% stars, 30d · Default branch at 0.4.1, ahead of CRAN 0.4.0 (checked 2026-10-21)
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
not measured
Median days to close, 50 most recently updated closed PRs
1

Stars over time

2026-05-03 · 12026-07-07 · 2
PracticesBeta

5 development-tooling and community-health practices detected across 3 families in the upstream repository

Checks run against github.com/mohsaqr/cooccure on 2026-10-21.

Continuous integration (1)
GitHub Actions
Docs source (3)
pkgdown

GitHub Pages site last deployed 2026-10-08 · The repository has a site deploy workflow

Reproducibility and dev environment (1)
data-raw/
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-04-16
    Named in .Rbuildignore: .claude, CLAUDE.md
    Named in .gitignore: .claude, CLAUDE.md
    Commits: at least 34 crediting it in the message
Models named in its commits
  • Claude Sonnet 4.616 commits · Apr 2026
  • Claude Opus 4.610 commits · Apr 2026
  • Claude Opus 4.78 commits · Apr 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
9 external dependencies (excludes base and recommended)

Installing cooccure adds no packages beyond those that come with R.

Depends (1)
R >= 3.5.0
Imports (5)
graphicsMatrixmethodsstatsutils
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

Datasets

People & History

People (3)
Author, Maintainer since 0.1.1 (2026), Copyright holder
Author, Copyright holder
Author, Copyright holder
Releases (2)

Pick two releases to compare their code metrics.

  • 0.4.0Latest
    record
    2026-07-22 · current release · diff ↗
  • 0.1.1
    record
    2026-04-24
  • R
    R 4.6.0 released · 2026-04-24
  • R
    R 4.5.0 released · 2025-04-11

Package metadata

First published
2026-04-24
Total releases
2 / 1 yrs
License
MIT + file LICENSE OSI
Minimum R
≥ 3.5.0
Bundled data
49 KB / 4 files
Download size
846 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("cooccure")
Saqr, M., López-Pernas, S., & Misiejuk, K. (2026). cooccure: Co-Occurrence Network Construction and Manipulation (Version 0.4.0) [Computer software]. https://doi.org/10.32614/CRAN.package.cooccure

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for cooccure version 0.4.0 [Data set]. HJJB, LLC. Data release v2026-10-24. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy