Skip to content

[upstream rENA 0.3.1] Regression axes named after the first edge, not the predictor #2

Open

Description

@HUDongpin

This is an issue in rENA 0.3.1, not in ena-python. It is tracked here because it came out of porting rENA to Python. Reported as an observation, not an accusation — it may be fixed upstream or intended, in which case please correct me. Full write-up: docs/rena-upstream-issues.md

Summary

ena.rotate.by.hena.regression names its rotation axes after the first edge rather than the predictor. With both x_var and y_var, both columns get the same name.

Severity: low — cosmetic, but produces duplicate column names.

Setup (rENA 0.3.1, R 4.4.2)
library(rENA)
rows <- data.frame(
  unit  = rep(paste0("U", 1:6), each = 4),
  conv  = rep(rep(c("c1", "c2"), each = 2), times = 6),
  grp   = rep(c("g1", "g2"), each = 12),
  score = rep(c(10, 20, 30, 40, 50, 60), each = 4),
  A = c(1,0,1,0, 0,1,1,1, 1,1,0,1, 0,0,1,0, 1,0,0,1, 0,1,1,0),
  B = c(0,1,1,1, 1,1,0,0, 0,1,1,0, 1,0,0,1, 0,1,1,0, 1,0,0,1),
  C = c(1,1,0,0, 1,0,1,0, 1,0,0,1, 0,1,1,1, 1,1,0,0, 0,0,1,1),
  D = c(0,0,1,1, 0,1,0,1, 0,1,1,0, 1,1,0,0, 0,0,1,1, 1,1,0,0),
  stringsAsFactors = FALSE)
acc <- ena.accumulate.data(
  units = rows[, "unit", drop = FALSE], conversation = rows[, "conv", drop = FALSE],
  metadata = rows[, c("grp", "score")], codes = rows[, c("A","B","C","D")],
  window.size.back = 2)
set <- ena.make.set(acc, dimensions = 2)

Reproduce

colnames(ena.rotate.by.hena.regression(set, list(x_var = "V ~ score"))$rotation)
#> [1] "A & B_reg" "SVD2" "SVD3" "SVD4" "SVD5" "SVD6"
#         ^ expected "score_reg"

colnames(ena.rotate.by.hena.regression(set,
  list(x_var = "V ~ score", y_var = "V ~ grp"))$rotation)
#> [1] "A & B_reg" "A & B_reg" "SVD3" "SVD4" "SVD5" "SVD6"
#         ^ both axes get the same name

Root cause

ena.rotate.by.regression.R:75 derives the name with xName <- all.vars(x)[2], which assumes x is a formula object. params$x_var is a character string, and all.vars() on a string returns nothing:

all.vars("V ~ score")               #> character(0)   -> all.vars(x)[2] is NA
all.vars(as.formula("V ~ score"))   #> [1] "V" "score"

So is.na(all.vars(x)[2]) is always TRUE and the branch falls back to xName <- names(v1)[1] — the first edge name. Line 121 does the same for yName, so with both axes the columns collide.

Suggested fix

Coerce first, e.g. all.vars(as.formula(x))[2].

What ena-python does

Names the axis after the predictor (score_reg, grp_reg). Names are cosmetic and the vectors match, so ena-python does not reproduce this.

Activity

  1. added
    upstream-renaDefect in rENA (upstream reference implementation), not in pyENA
    on Jul 15, 2026
  2. HUDongpin commented on Jul 16, 2026

    @HUDongpin
    OwnerAuthor

    Reported upstream: rENA #50 (2026-07-16).

    The report there pins its source references to rENA main @ a09a4b20, verified byte-identical to the released 0.3.1 this was found against — so it applies to their current tree, not just the CRAN build.

    This issue stays open here as ena-python's record of the divergence; it can close when the upstream one resolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-renaDefect in rENA (upstream reference implementation), not in pyENA

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions