Skip to content

Commit

Permalink
Merge pull request #2 from MichaelChirico/by-comma
Browse files Browse the repository at this point in the history
Provide column names as vector, not CSV
  • Loading branch information
victor-navarro committed Apr 9, 2024
2 parents 28a0ce6 + f592c93 commit f3ca204
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/model_graphs.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ calmr_model_graph <- function(
# aggregate data
x <- data.table::setDT(x)[trial == t,
list("value" = mean(value)),
by = "s1,s2"
by = c("s1","s2")
]
net <- ggnetwork::ggnetwork(network::as.network(x, loops = loops),
layout = "circle",
Expand Down
4 changes: 2 additions & 2 deletions R/model_parsers.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@
# type is the type of data
.aggregate_results_data_table <- function(dat, model, type) {
value <- time <- NULL # local binding
common_terms <- "group,phase,trial_type,trial,block_size,s1"
common_terms <- c("group","phase","trial_type","trial","block_size","s1")
fmap <- formula_map()
form <- paste0(c(common_terms, fmap[[model]][[type]]), collapse = ",")
form <- c(common_terms, fmap[[model]][[type]])
dat <- data.table::data.table(dat)
if (!("time" %in% names(dat))) {
data.table::setDT(dat)[, list("value" = mean(value)), by = form]
Expand Down
4 changes: 2 additions & 2 deletions vignettes/calmr_fits.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ so we know what to aim for.
```{r}
pati_summ <- setDT(pati)[,
list("rpert" = mean(rpert)),
by = "block,us,response"
by = c("block","us","response")
]
# set order (relevant for the future)
setorder(pati_summ, block, response, us)
Expand Down Expand Up @@ -163,7 +163,7 @@ my_model_function <- function(pars, exper, full = FALSE) {
(response == "np" | (response == "lp" &
mapply(grepl, s1, trial_type)))]
# aggregate
responses <- responses[, list(value = mean(value)), by = "block,s2,response"]
responses <- responses[, list(value = mean(value)), by = c("block","s2","response")]
if (full) {
return(responses)
}
Expand Down

0 comments on commit f3ca204

Please sign in to comment.