Skip to content

Commit

Permalink
this should be
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 8, 2024
1 parent 4ecd1d0 commit c710673
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/demean.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,13 @@ degroup <- function(x,
})
# create de-meaned variables by subtracting the group mean from each individual value
person_means_list <- lapply(
seq_along(select),
function(i) dat[[select[i]]] - group_means_list[[i]][[length(by)]]
# select,
# function(i) dat[[i]] - stats::ave(dat[[i]], dat[[by[length(by)]]], FUN = gm_fun)
# seq_along(select),
# function(i) dat[[select[i]]] - group_means_list[[i]][[length(by)]]
select,
function(i) {
dat$higher_levels <- do.call(paste, c(dat[by], list(sep = "_")))
dat[[i]] - stats::ave(dat[[i]], dat$higher_levels, FUN = gm_fun)
}
)
} else {
# cross-classified design: by > 1
Expand Down

0 comments on commit c710673

Please sign in to comment.