-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better get_anova(), added add_group_column()
- Loading branch information
1 parent
a259ba8
commit af99149
Showing
50 changed files
with
508 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Type: Package | ||
Package: BioMathR | ||
Title: Utility functions used at BioMath | ||
Version: 0.6.0 | ||
Version: 0.7.0 | ||
Authors@R: c( | ||
person("Paul", "Schmidt", email = "[email protected]", role = c("aut", "cre")), | ||
person("BioMath", role = "fnd") | ||
|
@@ -46,6 +46,7 @@ Suggests: | |
lme4, | ||
lmerTest, | ||
MetBrewer, | ||
nlme, | ||
openair, | ||
pdftools, | ||
performance, | ||
|
@@ -59,3 +60,4 @@ Config/testthat/edition: 3 | |
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.2.3 | ||
Roxygen: list(markdown = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' Add Group Column | ||
#' | ||
#' This function adds a new column to a data frame with a specified name. The new column indicates groups based on the grouping variables provided. When no grouping variable is provided, a default value is assigned to the new column. | ||
#' | ||
#' @param data A data frame. | ||
#' @param name The name of the new column to be added. | ||
#' @param group_by A vector of strings specifying the column names used for grouping. Default is NULL. | ||
#' | ||
#' @return A data frame with the new column added. | ||
#' @examples | ||
#' \dontrun{ | ||
#' data <- data.frame(x = c(1,2,3,1,2,3), y = c("a","b","c","a","b","c")) | ||
#' data %>% add_group_column(name = "group_id", group_by = c("x", "y")) | ||
#' } | ||
#' | ||
#' @export | ||
#' | ||
add_group_column <- function(data, name, group_by = NULL) { | ||
if (is.null(group_by)) { | ||
data[[name]] <- as.factor("-") | ||
return(data) | ||
} else { | ||
data <- data %>% | ||
group_by(across(all_of(group_by))) %>% | ||
mutate(temp____col = paste0(name, str_pad(cur_group_id(), width = 2, pad = "0")) %>% as.factor()) %>% | ||
ungroup() | ||
|
||
names(data)[which(names(data) == "temp____col")] <- name | ||
return(data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.