Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue #94 #96

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: improved version that keeps all of user's data.
  • Loading branch information
eli-daniels committed Apr 26, 2024
commit e6fb3b7ccbef7a8203c28c1eca16827b98925eba
8 changes: 5 additions & 3 deletions R/excel_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ transpose_data <- function(data, vars, group) {
}


#' @importFrom data.table := .N
dcast_data <- function(data, x, y, group) {
dataset <- as.data.table(data)
form_str <- sprintf("%s + data.table::rowid(%s, prefix = 'dcast_dummy') ~ %s", x, x, group)
dataset <- dataset[, c(".fake_id.") := list(seq_len(.N)), by = c(x, group)]
form_str <- sprintf("%s + .fake_id. ~ %s", x, group)
out <- dcast.data.table(
dataset,
formula = as.formula(form_str),
fill = NA,
value.var = y
fill = NA, value.var = y
)
out$.fake_id. <- NULL
setDF(out)
out
}
Expand Down
Loading