easystats / easystats/datawizard

expand `demean` to `degroup`

Open
#24 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
238
Forks
18
Avg merge
1d 15h
Merged PRs (30d)
4

Description

Some ideas for expanding the demean function into a more general degroup (or decenter, or ??) function (listed by ease of implementation as I perceive it):

  1. Allow for group-centering around other functions. Popular choices I've seen: median(), min(), max(), also Mode() is popular for categorical predictors.
Mode <- function(x, multimodal = FALSE) {
  uniqv <- unique(x)
  tab <- tabulate(match(x, uniqv))
  if (multimodal) {
    idx <- which(tab==max(tab))
  } else {
    idx <- which.max(tab)
  }
  uniqv[idx]
}
  1. Allow for more than 1 grouping var
    Order of operations would be: split y by G1, then split y_between by G2, etc... (Would need a better naming scheme?)

  2. Center around an indexed value. For example, center y around y[time==0], or y[condition=="a"]. Can be mixed with (1): max(y[time==0]), etc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing demean function and its surrounding documentation and tests. Compare the proposed centering functions, multiple grouping variables, and indexed reference values, then clarify which scope and naming should be accepted. Done means one agreed API is implemented with documented behavior and coverage for its supported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.