diff --git a/DESCRIPTION b/DESCRIPTION
index 86fa2b15..11780d61 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: faux
Title: Simulation Functions
-Version: 0.0.0.9006
-Date: 2019-05-02
+Version: 0.0.0.9007
+Date: 2019-05-06
Authors@R: person(given = "Lisa", family = "DeBruine", role = c("aut", "cre"), email = "debruine@gmail.com", comment = c(ORCID = "0000-0002-7523-5539"))
Description: Provides functions for simulating multiple variables with specified relationships.
Depends:
@@ -16,12 +16,14 @@ Imports:
tibble,
tidyselect,
stats,
- ggplot2
+ ggplot2,
+ rlang
License: MIT + file LICENSE
Suggests:
testthat (>= 2.1.0),
knitr,
- rmarkdown
+ rmarkdown,
+ forcats
VignetteBuilder: knitr
RoxygenNote: 6.1.1
Encoding: UTF-8
diff --git a/NAMESPACE b/NAMESPACE
index 2bada45d..fa88da6e 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -9,6 +9,7 @@ export(get_design_long)
export(is_pos_def)
export(long2wide)
export(make_id)
+export(plot_design)
export(pos_def_limits)
export(rnorm_multi)
export(rnorm_pre)
diff --git a/NEWS.md b/NEWS.md
index 940dca9c..7633459d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -10,4 +10,11 @@
# faux 0.0.0.9006
* Changes to argument order and names (more consistent, but may break old scripts)
-* Updated vignettes
\ No newline at end of file
+* Updated vignettes
+
+# faux 0.0.0.9007
+
+* Added a plot option to `check_design()` and `sim_design()`
+* Design lists returned by `check_design()` have a more consistent format
+ - n, mu, and sd are all data frames with between-cells as rows and within-cells as columns
+ - `within` and `between` are named lists; factors and labels are no longer separately named
\ No newline at end of file
diff --git a/R/check_design.R b/R/check_design.R
index 33db726b..3631d1c4 100644
--- a/R/check_design.R
+++ b/R/check_design.R
@@ -8,6 +8,7 @@
#' @param mu a vector giving the means of the variables (numeric vector of length 1 or vars)
#' @param sd the standard deviations of the variables (numeric vector of length 1 or vars)
#' @param r the correlations among the variables (can be a single number, vars\*vars matrix, vars\*vars vector, or a vars\*(vars-1)/2 vector)
+#' @param plot whether to show a plot of the design
#'
#' @return list
#'
@@ -20,7 +21,7 @@
#' @export
#'
check_design <- function(within = list(), between = list(),
- n = 100, mu = 0, sd = 1, r = 0) {
+ n = 100, mu = 0, sd = 1, r = 0, plot = TRUE) {
# name anonymous factors
if (is.numeric(within) && within %in% 2:10 %>% mean() == 1) { # vector of level numbers
within_names <- LETTERS[1:length(within)]
@@ -42,20 +43,11 @@ check_design <- function(within = list(), between = list(),
# if within or between factors are named vectors,
# use their names as column names and values as labels for plots
- between_labels <- purrr::map(between, fix_name_labels)
- between <- lapply(between_labels, names)
- within_labels <- purrr::map(within, fix_name_labels)
- within <- lapply(within_labels, names)
-
- within_factors <- names(within)
- between_factors <- names(between)
-
- # handle no w/in or btwn
- if (length(between_factors) == 0) between_factors <- ".tmpvar."
- if (length(within_factors) == 0) within_factors <- ".tmpvar."
+ between <- purrr::map(between, fix_name_labels)
+ within <- purrr::map(within, fix_name_labels)
# check for duplicate factor names
- factor_overlap <- intersect(within_factors, between_factors)
+ factor_overlap <- intersect(names(within), names(between))
if (length(factor_overlap)) {
stop("You have multiple factors with the same name (",
paste(factor_overlap, collapse = ", "),
@@ -78,52 +70,61 @@ check_design <- function(within = list(), between = list(),
}
# define columns
- if (length(within) == 0) {
- cells_w = "val"
- } else {
- cells_w <- do.call(expand.grid, within) %>%
- tidyr::unite("b", 1:ncol(.)) %>% dplyr::pull("b")
- }
- if (length(between) == 0) {
- cells_b = ".tmpvar."
- } else {
- cells_b <- do.call(expand.grid, between) %>%
- tidyr::unite("b", 1:ncol(.)) %>% dplyr::pull("b")
- }
+ cells_w <- cell_combos(within)
+ cells_b <- cell_combos(between)
# convert n, mu and sd from vector/list formats
cell_n <- convert_param(n, cells_w, cells_b, "Ns")
cell_mu <- convert_param(mu, cells_w, cells_b, "means")
cell_sd <- convert_param(sd, cells_w, cells_b, "SDs")
- # figure out number of subjects and their IDs
- sub_n <- sum(cell_n[1,])
- sub_id <- make_id(sub_n)
-
# set up cell correlations from r (number, vector, matrix or list styles)
cell_r <- list()
if (length(within)) {
for (cell in cells_b) {
cell_cor <- if(is.list(r)) r[[cell]] else r
- cell_r[[cell]] <- cormat(cell_cor, length(cells_w))
+ mat <- cormat(cell_cor, length(cells_w))
+ rownames(mat) <- cells_w
+ colnames(mat) <- cells_w
+ cell_r[[cell]] <- mat
}
}
- list(
+ design <- list(
within = within,
between = between,
- within_factors = within_factors,
- between_factors = between_factors,
- within_labels = within_labels,
- between_labels = between_labels,
cells_w = cells_w,
cells_b = cells_b,
cell_n = cell_n,
cell_mu = cell_mu,
cell_sd = cell_sd,
- cell_r = cell_r,
- sub_id = sub_id
+ cell_r = cell_r
)
+
+ if (plot) { plot_design(design) %>% print() }
+
+ invisible(design)
+}
+
+#' Cell combos
+#'
+#' Creates wide cell combination names, such as A1_B1, A2_B1, A1_B2, A2_B2.
+#'
+#' @param factors A list of factors
+#'
+#' @return a list
+#' @keywords internal
+#'
+cell_combos <- function(factors) {
+ if (length(factors) == 0) {
+ cells = "val"
+ } else {
+ cells <- lapply(factors, names) %>%
+ do.call(expand.grid, .) %>%
+ tidyr::unite("b", 1:ncol(.)) %>% dplyr::pull("b")
+ }
+
+ cells
}
#' Convert parameter
@@ -203,121 +204,9 @@ convert_param <- function (param, cells_w, cells_b, type = "this parameter") {
}
}
- dd <- matrix(param2, ncol = b_n) %>% as.data.frame()
- names(dd) <- cells_b
+ dd <- matrix(param2, ncol = b_n)
+ colnames(dd) <- cells_b
rownames(dd) <- cells_w
- dd
-}
-
-
-#' Get design from long data
-#'
-#' Makes a best guess at the design of a long-format data frame.
-#' Finds all columns that contain a single value per unit of analysis (between factors),
-#' all columns that contain the same values per unit of analysis (within factors), and
-#' all columns that differ over units of analysis (dv, continuous factors)
-#'
-#' @param .data the data frame (in long format)
-#' @param id the column name(s) that identify a unit of analysis
-#' @param dv the column name that identifies the DV
-#'
-#' @return the data frame in long format
-#'
-#' @export
-#'
-get_design_long <- function(.data, id = "sub_id", dv = "val") {
- between_factors <- .data %>%
- dplyr::group_by_at(dplyr::vars(tidyselect::one_of(id))) %>%
- dplyr::summarise_all(dplyr::n_distinct) %>%
- dplyr::ungroup() %>%
- dplyr::select(-tidyselect::one_of(id)) %>%
- dplyr::summarise_all(max) %>%
- dplyr::select_if(~ . == 1) %>%
- names()
-
- within_factors <- .data %>%
- dplyr::select(-tidyselect::one_of(between_factors)) %>%
- dplyr::group_by_at(dplyr::vars(tidyselect::one_of(id))) %>%
- dplyr::summarise_all(paste0, collapse = ",") %>%
- dplyr::ungroup() %>%
- dplyr::select(-tidyselect::one_of(id)) %>%
- dplyr::summarise_all(dplyr::n_distinct) %>%
- dplyr::select_if(~ . == 1) %>%
- names()
-
- within <- .data %>%
- dplyr::select(tidyselect::one_of(within_factors)) %>%
- dplyr::mutate_all(as.factor) %>%
- dplyr::summarise_all(~levels(.) %>% paste0(collapse = ".|.")) %>%
- as.list() %>%
- sapply(strsplit, split=".|.", fixed = TRUE)
-
- between <- .data %>%
- dplyr::select(tidyselect::one_of(between_factors)) %>%
- dplyr::mutate_all(as.factor) %>%
- dplyr::summarise_all(~levels(.) %>% paste0(collapse = ".|.")) %>%
- as.list() %>%
- sapply(strsplit, split=".|.", fixed = TRUE)
-
- between_labels <- purrr::map(between, fix_name_labels)
- within_labels <- purrr::map(within, fix_name_labels)
-
- cells_b <- do.call(expand.grid, between) %>%
- tidyr::unite("b", 1:ncol(.)) %>% dplyr::pull("b")
-
- cells_w <- do.call(expand.grid, within) %>%
- tidyr::unite("b", 1:ncol(.)) %>% dplyr::pull("b")
-
- # get n, mu, sd, r per cell
- chk <- check_sim_stats(.data, between_factors, within_factors, dv, id)
-
- n <- chk %>%
- tidyr::unite(".within", tidyselect::one_of(between_factors)) %>%
- dplyr::select(.within, var, n) %>%
- tidyr::spread(var, n) %>%
- tibble::column_to_rownames(".within")
-
- mu <- chk %>%
- tidyr::unite(".within", tidyselect::one_of(between_factors)) %>%
- dplyr::select(.within, var, mean) %>%
- tidyr::spread(var, mean) %>%
- tibble::column_to_rownames(".within")
-
- sd <- chk %>%
- tidyr::unite(".within", tidyselect::one_of(between_factors)) %>%
- dplyr::select(.within, var, sd) %>%
- tidyr::spread(var, sd) %>%
- tibble::column_to_rownames(".within")
-
- cors <- chk %>%
- tidyr::unite(".between", tidyselect::one_of(between_factors)) %>%
- dplyr::select(tidyselect::one_of(c(".between", "var", cells_w))) %>%
- dplyr::mutate(var = forcats::fct_relevel(var, cells_w)) %>%
- dplyr::arrange(var) %>%
- dplyr::group_by(.between) %>%
- tidyr::nest(.key = "r") %>%
- as.list()
-
- r <- purrr::map(cors$r, ~tibble::column_to_rownames(., "var"))
- names(r) <- cors$.between
-
- design <- list(
- within = within,
- between = between,
- within_factors = within_factors,
- between_factors = between_factors,
- within_labels = within_labels,
- between_labels = between_labels,
- cells_w = cells_w,
- cells_b = cells_b,
- cell_n = n,
- cell_mu = mu,
- cell_sd = sd,
- cell_r = r,
- sub_id = id
- )
-
- design
+ t(dd) %>% as.data.frame()
}
-
diff --git a/R/get_design_long.R b/R/get_design_long.R
new file mode 100644
index 00000000..4666b49a
--- /dev/null
+++ b/R/get_design_long.R
@@ -0,0 +1,112 @@
+#' Get design from long data
+#'
+#' Makes a best guess at the design of a long-format data frame.
+#' Finds all columns that contain a single value per unit of analysis (between factors),
+#' all columns that contain the same values per unit of analysis (within factors), and
+#' all columns that differ over units of analysis (dv, continuous factors)
+#'
+#' @param .data the data frame (in long format)
+#' @param id the column name(s) that identify a unit of analysis
+#' @param dv the column name that identifies the DV
+#'
+#' @return the data frame in long format
+#'
+#' @export
+#'
+get_design_long <- function(.data, id = "sub_id", dv = "val") {
+ between_factors <- .data %>%
+ dplyr::group_by_at(dplyr::vars(tidyselect::one_of(id))) %>%
+ dplyr::summarise_all(dplyr::n_distinct) %>%
+ dplyr::ungroup() %>%
+ dplyr::select(-tidyselect::one_of(id)) %>%
+ dplyr::summarise_all(max) %>%
+ dplyr::select_if(~ . == 1) %>%
+ names()
+
+ within_factors <- .data %>%
+ dplyr::select(-tidyselect::one_of(between_factors)) %>%
+ dplyr::group_by_at(dplyr::vars(tidyselect::one_of(id))) %>%
+ dplyr::summarise_all(paste0, collapse = ",") %>%
+ dplyr::ungroup() %>%
+ dplyr::select(-tidyselect::one_of(id)) %>%
+ dplyr::summarise_all(dplyr::n_distinct) %>%
+ dplyr::select_if(~ . == 1) %>%
+ names()
+
+ within <- .data %>%
+ dplyr::select(tidyselect::one_of(within_factors)) %>%
+ dplyr::mutate_all(as.factor) %>%
+ dplyr::summarise_all(~levels(.) %>% paste0(collapse = ".|.")) %>%
+ as.list() %>%
+ sapply(strsplit, split=".|.", fixed = TRUE) %>%
+ purrr::map(fix_name_labels)
+
+ between <- .data %>%
+ dplyr::select(tidyselect::one_of(between_factors)) %>%
+ dplyr::mutate_all(as.factor) %>%
+ dplyr::summarise_all(~levels(.) %>% paste0(collapse = ".|.")) %>%
+ as.list() %>%
+ sapply(strsplit, split=".|.", fixed = TRUE) %>%
+ purrr::map(fix_name_labels)
+
+ # define columns
+ cells_w <- cell_combos(within)
+ cells_b <- cell_combos(between)
+
+ # get n, mu, sd, r per cell
+ chk <- check_sim_stats(.data, between_factors, within_factors, dv, id)
+
+ if (length(between_factors)) {
+ chk_b <- tidyr::unite(chk, ".between", tidyselect::one_of(between_factors)) %>%
+ dplyr::mutate(.between = forcats::fct_relevel(.between, cells_b)) %>%
+ dplyr::arrange(.between)
+ } else {
+ chk_b <- dplyr::mutate(chk, ".between" = dv)
+ }
+
+ n <- chk_b %>%
+ dplyr::select(.between, var, n) %>%
+ tidyr::spread(var, n) %>%
+ dplyr::select(tidyselect::one_of(c(".between", cells_w))) %>%
+ tibble::column_to_rownames(".between") %>%
+ as.data.frame()
+
+ mu <- chk_b %>%
+ dplyr::select(.between, var, mean) %>%
+ tidyr::spread(var, mean) %>%
+ dplyr::select(tidyselect::one_of(c(".between", cells_w))) %>%
+ tibble::column_to_rownames(".between") %>%
+ as.data.frame()
+
+ sd <- chk_b %>%
+ dplyr::select(.between, var, sd) %>%
+ tidyr::spread(var, sd) %>%
+ dplyr::select(tidyselect::one_of(c(".between", cells_w))) %>%
+ tibble::column_to_rownames(".between") %>%
+ as.data.frame()
+
+ cors <- chk_b %>%
+ dplyr::select(tidyselect::one_of(c(".between", "var", cells_w))) %>%
+ dplyr::mutate(var = forcats::fct_relevel(var, cells_w)) %>%
+ dplyr::arrange(var) %>%
+ dplyr::group_by(.between) %>%
+ tidyr::nest(.key = "r") %>%
+ as.list()
+
+ r <- purrr::map(cors$r, ~tibble::column_to_rownames(., "var") %>% as.matrix())
+ names(r) <- cors$.between
+
+ design <- list(
+ within = within,
+ between = between,
+ cells_w = cells_w,
+ cells_b = cells_b,
+ cell_n = n,
+ cell_mu = mu,
+ cell_sd = sd,
+ cell_r = r
+ )
+
+ design
+}
+
diff --git a/R/plot_design.R b/R/plot_design.R
new file mode 100644
index 00000000..9860613a
--- /dev/null
+++ b/R/plot_design.R
@@ -0,0 +1,66 @@
+#' Plot design
+#'
+#' \code{plot_design()} plots the specified within and between design
+#'
+#' @param design A list of design parameters created by check_design() or a data tbl (in long format)
+#' @param id the column name(s) that identify a unit of analysis
+#' @param dv the column name that identifies the DV
+#'
+#' @return plot
+#'
+#' @examples
+#'
+#' within <- list(time = c("day", "night"))
+#' between <- list(pet = c("dog", "cat"))
+#' check_design(within, between) %>% plot_design()
+#'
+#' @export
+#'
+plot_design <- function(design, id = "sub_id", dv = "val") {
+ if (!is.data.frame(design) && is.list(design)) {
+ data <- sim_design_(design, empirical = TRUE, long = TRUE)
+ } else if (is.data.frame(design)) {
+ data <- design
+ design <- get_design_long(data, id = id, dv = dv)
+ } else {
+ stop("design must be a design list or a data frame")
+ }
+
+ factors <- c(names(design$within), names(design$between))
+ factor_n <- length(factors)
+ f <- dplyr::syms(factors) # make it possible to use strings to specify columns
+
+ if (factor_n == 1) {
+ p <- ggplot2::ggplot(data, ggplot2::aes(!!f[[1]], val))
+ } else if (factor_n == 2) {
+ p <- ggplot2::ggplot(data, ggplot2::aes(!!f[[1]], val, color = !!f[[2]]))
+ } else if (factor_n == 3) {
+ p <- ggplot2::ggplot(data, ggplot2::aes(!!f[[1]], val, color = !!f[[2]])) +
+ ggplot2::facet_grid(
+ eval(rlang::expr(!!f[[3]] ~ .)),
+ labeller = "label_both"
+ )
+ } else {
+ p <- ggplot2::ggplot(data, ggplot2::aes(!!f[[1]], val, color = !!f[[2]])) +
+ ggplot2::facet_grid(
+ eval(rlang::expr(!!f[[3]] ~ !!f[[4]])),
+ labeller = "label_both"
+ )
+
+ if (factor_n > 4) message("Can't plot more than 4 factors")
+ }
+
+ minsd <- function(x) { mean(x) - sd(x) }
+ maxsd <- function(x) { mean(x) + sd(x) }
+
+ p <- p + ggplot2::stat_summary(fun.y = mean,
+ fun.ymin = minsd,
+ fun.ymax = maxsd,
+ geom='pointrange',
+ shape = 10,
+ size = 1,
+ position = ggplot2::position_dodge(width = 0.9))
+ p <- p + ggplot2::theme_bw()
+
+ p
+}
diff --git a/R/rnorm_multi.R b/R/rnorm_multi.R
index 6e44c8ce..6e04e753 100644
--- a/R/rnorm_multi.R
+++ b/R/rnorm_multi.R
@@ -43,12 +43,18 @@ rnorm_multi <- function(n, vars = 3, mu = 0, sd = 1, r = 0,
mu <- rep(mu, vars)
} else if (length(mu) != vars) {
stop("the length of mu must be 1 or vars");
+ } else {
+ # get rid of names
+ mu <- as.matrix(mu) %>% as.vector()
}
if (length(sd) == 1) {
sd <- rep(sd, vars)
} else if (length(sd) != vars) {
stop("the length of sd must be 1 or vars");
+ } else {
+ # get rid of names
+ sd <- as.matrix(sd) %>% as.vector()
}
cor_mat <- cormat(r, vars)
diff --git a/R/sim_design.R b/R/sim_design.R
index 103d530a..0c7ac012 100644
--- a/R/sim_design.R
+++ b/R/sim_design.R
@@ -10,6 +10,7 @@
#' @param r the correlations among the variables (can be a single number, vars\*vars matrix, vars\*vars vector, or a vars\*(vars-1)/2 vector)
#' @param empirical logical. If true, mu, sd and r specify the empirical not population mean, sd and covariance
#' @param long Whether the returned tbl is in wide (default = FALSE) or long (TRUE) format
+#' @param plot whether to show a plot of the design
#'
#' @return a tbl
#'
@@ -17,10 +18,10 @@
#'
sim_design <- function(within = list(), between = list(),
n = 100, mu = 0, sd = 1, r = 0,
- empirical = FALSE, long = FALSE) {
+ empirical = FALSE, long = FALSE, plot = FALSE) {
# check the design is specified correctly
design <- check_design(within = within, between = between,
- n = n, mu = mu, sd = sd, r = r)
+ n = n, mu = mu, sd = sd, r = r, plot = plot)
# simulate the data
sim_design_(design, empirical = empirical, long = long)
@@ -57,20 +58,33 @@ fix_name_labels <- function(x) {
sim_design_ <- function(design, empirical = FALSE, long = FALSE) {
list2env(design, envir = environment())
+ # get factor names
+ within_factors <- names(within)
+ between_factors <- names(between)
+
+ # handle no w/in or btwn
+ if (length(between_factors) == 0) between_factors <- ".tmpvar."
+ if (length(within_factors) == 0) within_factors <- ".tmpvar."
+
+ # figure out number of subjects and their IDs
+ sub_n <- sum(cell_n[,1])
+ sub_id <- make_id(sub_n)
+
# simulate data for each between-cell
for (cell in cells_b) {
if (length(within)) {
cell_vars <- rnorm_multi(
- cell_n[1,cell], length(cells_w),
- cell_mu[[cell]], cell_sd[[cell]], cell_r[[cell]],
- cells_w, empirical
+ n = cell_n[cell,1], vars = length(cells_w),
+ mu = cell_mu[cell,], sd = cell_sd[cell,], r = cell_r[[cell]],
+ varnames = cells_w, empirical = empirical
) %>%
dplyr::mutate("btwn" = cell)
} else {
# fully between design
- val <- MASS::mvrnorm(n = cell_n[1,cell],
- mu = cell_mu[[cell]],
- Sigma = cell_sd[[cell]] %*% t(cell_sd[[cell]]),
+ sd2 <- cell_sd[cell,] %>% as.matrix() %>% as.vector()
+ val <- MASS::mvrnorm(n = cell_n[cell,1],
+ mu = cell_mu[cell,] %>% as.matrix() %>% as.vector(),
+ Sigma = sd2 %*% t(sd2),
empirical = empirical)
cell_vars <- data.frame("val" = val) %>%
dplyr::mutate("btwn" = cell)
@@ -95,10 +109,11 @@ sim_design_ <- function(design, empirical = FALSE, long = FALSE) {
dplyr::mutate_at(c(between_factors), ~as.factor(.)) %>%
dplyr::select(tidyselect::one_of(col_order))
- # FIX: put factors in order
- #for (f in between_factors) {
- # df_wide[[f]] <- factor(df_wide[[f]], levels = between[[f]])
- #}
+ # put factors in order
+ factors_to_order <- setdiff(between_factors, ".tmpvar.")
+ for (f in factors_to_order) {
+ df_wide[[f]] <- factor(df_wide[[f]], levels = names(between[[f]]))
+ }
if (long == TRUE && length(within)) {
# not necessary for fully between designs
@@ -111,10 +126,11 @@ sim_design_ <- function(design, empirical = FALSE, long = FALSE) {
dplyr::select(tidyselect::one_of(col_order)) %>%
dplyr::mutate_at(within_factors, ~as.factor(.))
- #FIX: put factors in order
- #for (f in within_factors) {
- # df_long[[f]] <- factor(df_long[[f]], levels = within[[f]])
- #}
+ # put factors in order
+ factors_to_order <- setdiff(within_factors, ".tmpvar.")
+ for (f in factors_to_order) {
+ df_long[[f]] <- factor(df_long[[f]], levels = names(within[[f]]))
+ }
return(df_long)
}
diff --git a/README.Rmd b/README.Rmd
index c2c1f805..867ede2d 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -27,16 +27,24 @@ set.seed(200)
```
-It is useful to be able to simulate data with a specified structure. The `faux` package provides some functions to make this process easier.
+It is useful to be able to simulate data with a specified structure. The `faux` package provides some functions to make this process easier. See the [package website](https://debruine.github.io/faux/) for more details.
+
+## Installation
+
+You can install the newest version of faux from [GitHub](https://github.com/debruine/faux) with:
+
+``` r
+devtools::install_github("debruine/faux")
+```
## sim_design
-This function creates a dataset with a specific between- and within-subjects design. [see vignette](articles/sim_design.html)
+This function creates a dataset with a specific between- and within-subjects design. [see vignette](https://debruine.github.io/faux/articles/sim_design.html)
-For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is `pet` with twolevels of `cat` and `dog`. The within-subject factor is `time` with two levels of `day` and `night`. The mean for the `cat_day` cell is 10, the mean for the `cat_night` cell is 20, the mean for the `dog_day` cell is 15, and the mean for the `dog_night` cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set `empirical = FALSE` to sample from a population with these values).
+For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is `pet` with twolevels of `cat` and `dog`. The within-subject factor is `time` with two levels of `day` and `night`. The mean for the `cat_day` cell is 10, the mean for the `cat_night` cell is 20, the mean for the `dog_day` cell is 15, and the mean for the `dog_night` cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set `empirical = FALSE` to sample from a population with these values). Set `plot = TRUE` to show a plot of means and SDs.
-```{r}
+```{r, fig.width = 8, fig.height = 4}
between <- list("pet" = c("cat", "dog"))
within <- list("time" = c("day", "night"))
mu <- data.frame(
@@ -46,7 +54,7 @@ mu <- data.frame(
)
df <- sim_design(within, between,
n = 100, mu = mu, sd = 5, r = .5,
- empirical = TRUE)
+ empirical = TRUE, plot = TRUE)
```
`r check_sim_stats(df, between = "pet", usekable = TRUE)`
@@ -54,7 +62,7 @@ Table: Sample `sim_design()` stats
## rnorm_multi
-This function makes multiple normally distributed vectors with specified parameters and relationships. [see vignette](articles/rnorm_multi.html)
+This function makes multiple normally distributed vectors with specified parameters and relationships. [see vignette](https://debruine.github.io/faux/articles/rnorm_multi.html)
For example, the following creates a sample that has 100 observations of 3 variables, drawn from a population where A has a mean of 0 and SD of 1, while B and C have means of 20 and SDs of 5. A correlates with B and C with r = 0.5, and B and C correlate with r = 0.25.
@@ -78,7 +86,7 @@ Table: Sample `rnorm_multi()` stats
## sim_df
-This function produces a dataframe with the same distributions and correlations as an existing dataframe. It only returns numeric columns and simulates all numeric variables from a continuous normal distribution (for now). [see vignette](articles/sim_df.html)
+This function produces a dataframe with the same distributions and correlations as an existing dataframe. It only returns numeric columns and simulates all numeric variables from a continuous normal distribution (for now). [see vignette](https://debruine.github.io/faux/articles/sim_df.html)
For example, the following code creates a new sample from the built-in dataset `iris` with 50 observations of each species.
diff --git a/README_files/figure-markdown_github/plot-iris-sim-1.png b/README_files/figure-markdown_github/plot-iris-sim-1.png
deleted file mode 100644
index 819df6be..00000000
Binary files a/README_files/figure-markdown_github/plot-iris-sim-1.png and /dev/null differ
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index e30bd682..e02e9438 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -60,7 +60,7 @@
diff --git a/docs/articles/index.html b/docs/articles/index.html
index edd0368b..29027970 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -60,7 +60,7 @@
diff --git a/docs/articles/rnorm_multi.html b/docs/articles/rnorm_multi.html
index ee3f4a82..acc49b5c 100644
--- a/docs/articles/rnorm_multi.html
+++ b/docs/articles/rnorm_multi.html
@@ -30,7 +30,7 @@
@@ -82,7 +82,7 @@
rnorm_multi.Rmd
sim_design.Rmd
For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is pet
with twolevels of cat
and dog
. The within-subject factor is time
with two levels of day
and night
. The mean for the cat_day
cell is 10, the mean for the cat_night
cell is 20, the mean for the dog_day
cell is 15, and the mean for the dog_night
cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set empirical = FALSE
to sample from a population with these values).
For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is pet
with twolevels of cat
and dog
. The within-subject factor is time
with two levels of day
and night
. The mean for the cat_day
cell is 10, the mean for the cat_night
cell is 20, the mean for the dog_day
cell is 15, and the mean for the dog_night
cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set empirical = FALSE
to sample from a population with these values). Set plot = TRUE
to show a plot of means and SDs.
between <- list("pet" = c("cat", "dog"))
within <- list("time" = c("day", "night"))
mu <- data.frame(
@@ -103,7 +103,9 @@
dog = c(15, 25),
row.names = within$time
)
-df <- sim_design(within, between, n = 100, mu = mu, sd = 5, r = 0.5, empirical = TRUE)
pet | @@ -162,7 +164,8 @@
---|
sub_id | @@ -178,102 +181,102 @@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
S01 | C1 | --2.7038494 | --2.0031140 | --1.2463619 | -0.2395364 | --0.3551418 | --0.6613917 | +-0.5766912 | +0.0856008 | +0.9838375 | +-0.0126229 | +-1.5528052 | +0.0167980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S02 | C1 | --0.2574224 | --2.5189879 | --0.0945284 | --1.0963883 | --0.9231602 | --0.8312929 | +1.3673109 | +1.8875275 | +1.5626066 | +1.9393848 | +0.7511418 | +2.1436454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S03 | C1 | -0.9326960 | -0.5741398 | -0.9461607 | -1.5174811 | -0.1336817 | -2.2414371 | +0.0834231 | +-1.0287178 | +-0.6225890 | +0.3070957 | +1.5900014 | +0.8677457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S04 | C1 | --0.2846845 | --0.0003843 | --0.4205892 | -0.1429045 | -0.7309652 | --0.4047417 | +-1.3635503 | +-1.2068872 | +-0.7472159 | +-2.2844708 | +-1.3691766 | +-1.9300476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S05 | C1 | -0.0261954 | -0.5607634 | --1.2736072 | --1.0107932 | -1.3337995 | -0.2854269 | +0.0874826 | +-0.4472125 | +0.0760042 | +0.2692548 | +0.6108916 | +0.1959173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S06 | C2 | --0.9116783 | --1.0939985 | --1.0655517 | --0.9173210 | --1.4847558 | --2.5493564 | +-0.4425274 | +0.7653733 | +0.7165515 | +-0.7536628 | +0.0169834 | +-0.3760313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S07 | C2 | --0.0690060 | -0.4741805 | -0.3974194 | --0.1888221 | -0.0963150 | -1.4528341 | +1.1250722 | +1.0306602 | +-0.0446920 | +0.8599006 | +-0.3464750 | +0.2145361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S08 | C2 | --0.4591101 | -0.8723573 | --0.2708937 | --0.6212891 | -1.3480380 | -0.9535270 | +-0.0299556 | +1.0819144 | +1.1454149 | +0.9607333 | +0.3288986 | +1.7718617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S09 | C2 | -0.1287775 | --0.3451130 | --0.5767718 | --1.8759247 | --0.8973256 | --1.1960685 | +0.5363877 | +1.1655595 | +0.7289594 | +0.4044498 | +0.5081634 | +1.5661115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
S10 | C2 | -1.0623320 | -1.0175079 | --0.1675100 | -0.5620579 | -0.7513321 | -0.7814270 | +-0.5297062 | +-2.1894619 | +-2.2085771 | +-1.3405989 | +-1.4645263 | +-1.5222258 |
sim_df.Rmd
It is useful to be able to simulate data with a specified structure. The faux
package provides some functions to make this process easier.
It is useful to be able to simulate data with a specified structure. The faux
package provides some functions to make this process easier. See the package website for more details.
You can install the newest version of faux from GitHub with:
+devtools::install_github("debruine/faux")
This function creates a dataset with a specific between- and within-subjects design. see vignette
-For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is pet
with twolevels of cat
and dog
. The within-subject factor is time
with two levels of day
and night
. The mean for the cat_day
cell is 10, the mean for the cat_night
cell is 20, the mean for the dog_day
cell is 15, and the mean for the dog_night
cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set empirical = FALSE
to sample from a population with these values).
This function creates a dataset with a specific between- and within-subjects design. see vignette
+For example, the following creates a 2w*2b design with 100 observations in each cell. The between-subject factor is pet
with twolevels of cat
and dog
. The within-subject factor is time
with two levels of day
and night
. The mean for the cat_day
cell is 10, the mean for the cat_night
cell is 20, the mean for the dog_day
cell is 15, and the mean for the dog_night
cell is 25. All cells have a SD of 5 and all within-subject cells are correlated r = 0.5
. The resulting data has exactly these values (set empirical = FALSE
to sample from a population with these values). Set plot = TRUE
to show a plot of means and SDs.
between <- list("pet" = c("cat", "dog"))
within <- list("time" = c("day", "night"))
mu <- data.frame(
@@ -100,7 +106,8 @@
)
df <- sim_design(within, between,
n = 100, mu = mu, sd = 5, r = .5,
- empirical = TRUE)
100 | A | 1.00 | -0.62 | -0.46 | --0.05 | -1.08 | +0.36 | +0.50 | +0.15 | +0.96 |
100 | B | -0.62 | +0.36 | 1.00 | -0.19 | -19.95 | -5.38 | +0.18 | +19.37 | +5.20 |
100 | C | -0.46 | -0.19 | +0.50 | +0.18 | 1.00 | -19.81 | -5.15 | +20.56 | +5.29 |
This function produces a dataframe with the same distributions and correlations as an existing dataframe. It only returns numeric columns and simulates all numeric variables from a continuous normal distribution (for now). see vignette
+This function produces a dataframe with the same distributions and correlations as an existing dataframe. It only returns numeric columns and simulates all numeric variables from a continuous normal distribution (for now). see vignette
For example, the following code creates a new sample from the built-in dataset iris
with 50 observations of each species.
new_iris <- sim_df(iris, 50, "Species")
check_design()
and sim_design()
+check_design()
have a more consistent format
+within
and between
are named lists; factors and labels are no longer separately namedcheck_design(within = list(), between = list(), n = 100, mu = 0, - sd = 1, r = 0)+ sd = 1, r = 0, plot = TRUE)
@@ -168,22 +168,22 @@within <- list(time = c("day", "night")) between <- list(pet = c("dog", "cat")) -check_design(within, between)#> $within -#> $within$time -#> [1] "day" "night" -#> -#> -#> $between -#> $between$pet -#> [1] "dog" "cat" -#> -#> -#> $within_factors -#> [1] "time" -#> -#> $between_factors -#> [1] "pet" -#> -#> $within_labels -#> $within_labels$time -#> day night -#> "day" "night" -#> -#> -#> $between_labels -#> $between_labels$pet -#> dog cat -#> "dog" "cat" -#> -#> -#> $cell_n -#> dog cat -#> day 100 100 -#> night 100 100 -#> -#> $cell_mu -#> dog cat -#> day 0 0 -#> night 0 0 -#> -#> $cell_sd -#> dog cat -#> day 1 1 -#> night 1 1 -#> -#> $cell_r -#> $cell_r$dog -#> [,1] [,2] -#> [1,] 1 0 -#> [2,] 0 1 -#> -#> $cell_r$cat -#> [,1] [,2] -#> [1,] 1 0 -#> [2,] 0 1 -#> -#> -#> $cells_w -#> [1] "day" "night" -#> -#> $cells_b -#> [1] "dog" "cat" -#> -#> $sub_id -#> [1] "S001" "S002" "S003" "S004" "S005" "S006" "S007" "S008" "S009" "S010" -#> [11] "S011" "S012" "S013" "S014" "S015" "S016" "S017" "S018" "S019" "S020" -#> [21] "S021" "S022" "S023" "S024" "S025" "S026" "S027" "S028" "S029" "S030" -#> [31] "S031" "S032" "S033" "S034" "S035" "S036" "S037" "S038" "S039" "S040" -#> [41] "S041" "S042" "S043" "S044" "S045" "S046" "S047" "S048" "S049" "S050" -#> [51] "S051" "S052" "S053" "S054" "S055" "S056" "S057" "S058" "S059" "S060" -#> [61] "S061" "S062" "S063" "S064" "S065" "S066" "S067" "S068" "S069" "S070" -#> [71] "S071" "S072" "S073" "S074" "S075" "S076" "S077" "S078" "S079" "S080" -#> [81] "S081" "S082" "S083" "S084" "S085" "S086" "S087" "S088" "S089" "S090" -#> [91] "S091" "S092" "S093" "S094" "S095" "S096" "S097" "S098" "S099" "S100" -#> [101] "S101" "S102" "S103" "S104" "S105" "S106" "S107" "S108" "S109" "S110" -#> [111] "S111" "S112" "S113" "S114" "S115" "S116" "S117" "S118" "S119" "S120" -#> [121] "S121" "S122" "S123" "S124" "S125" "S126" "S127" "S128" "S129" "S130" -#> [131] "S131" "S132" "S133" "S134" "S135" "S136" "S137" "S138" "S139" "S140" -#> [141] "S141" "S142" "S143" "S144" "S145" "S146" "S147" "S148" "S149" "S150" -#> [151] "S151" "S152" "S153" "S154" "S155" "S156" "S157" "S158" "S159" "S160" -#> [161] "S161" "S162" "S163" "S164" "S165" "S166" "S167" "S168" "S169" "S170" -#> [171] "S171" "S172" "S173" "S174" "S175" "S176" "S177" "S178" "S179" "S180" -#> [181] "S181" "S182" "S183" "S184" "S185" "S186" "S187" "S188" "S189" "S190" -#> [191] "S191" "S192" "S193" "S194" "S195" "S196" "S197" "S198" "S199" "S200" -#>+check_design(within, between)
diff --git a/docs/reference/cormat.html b/docs/reference/cormat.html index 6abdb450..111b644f 100644 --- a/docs/reference/cormat.html +++ b/docs/reference/cormat.html @@ -63,7 +63,7 @@ diff --git a/docs/reference/cormat_from_triangle.html b/docs/reference/cormat_from_triangle.html index d7d2db61..c48e1c57 100644 --- a/docs/reference/cormat_from_triangle.html +++ b/docs/reference/cormat_from_triangle.html @@ -63,7 +63,7 @@ diff --git a/docs/reference/faceratings.html b/docs/reference/faceratings.html index 8ed382bd..209fed57 100644 --- a/docs/reference/faceratings.html +++ b/docs/reference/faceratings.html @@ -63,7 +63,7 @@ diff --git a/docs/reference/fix_name_labels.html b/docs/reference/fix_name_labels.html index a6041bfe..c17f5e09 100644 --- a/docs/reference/fix_name_labels.html +++ b/docs/reference/fix_name_labels.html @@ -63,7 +63,7 @@ diff --git a/docs/reference/get_design_long.html b/docs/reference/get_design_long.html index 5518b325..501f7b9f 100644 --- a/docs/reference/get_design_long.html +++ b/docs/reference/get_design_long.html @@ -66,7 +66,7 @@ diff --git a/docs/reference/index.html b/docs/reference/index.html index bedc5427..56fe4444 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -60,7 +60,7 @@ @@ -186,6 +186,12 @@check_sim_stats(iris, "Species")#> # A tibble: 12 x 9 ++#> <fct> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 setosa 50 Sepa… 1 0.74 0.27 0.28 5.01 +#> 2 setosa 50 Sepa… 0.74 1 0.18 0.23 3.43 +#> 3 setosa 50 Peta… 0.27 0.18 1 0.33 1.46 +#> 4 setosa 50 Peta… 0.28 0.23 0.33 1 0.25 +#> 5 versic… 50 Sepa… 1 0.53 0.75 0.55 5.94 +#> 6 versic… 50 Sepa… 0.53 1 0.56 0.66 2.77 +#> 7 versic… 50 Peta… 0.75 0.56 1 0.79 4.26 +#> 8 versic… 50 Peta… 0.55 0.66 0.79 1 1.33 +#> 9 virgin… 50 Sepa… 1 0.46 0.86 0.28 6.59 +#> 10 virgin… 50 Sepa… 0.46 1 0.4 0.54 2.97 +#> 11 virgin… 50 Peta… 0.86 0.4 1 0.32 5.55 +#> 12 virgin… 50 Peta… 0.28 0.54 0.32 1 2.03 +#> # … with 1 more variable: sd <dbl>check_sim_stats(iris, "Species")#> # A tibble: 12 x 9 #> Species n var Sepal.Length Sepal.Width Petal.Length Petal.Width mean -#> <fct> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 setosa 50 Sepa… 1 0.74 0.27 0.28 5.01 -#> 2 setosa 50 Sepa… 0.74 1 0.18 0.23 3.43 -#> 3 setosa 50 Peta… 0.27 0.18 1 0.33 1.46 -#> 4 setosa 50 Peta… 0.28 0.23 0.33 1 0.25 -#> 5 versic… 50 Sepa… 1 0.53 0.75 0.55 5.94 -#> 6 versic… 50 Sepa… 0.53 1 0.56 0.66 2.77 -#> 7 versic… 50 Peta… 0.75 0.56 1 0.79 4.26 -#> 8 versic… 50 Peta… 0.55 0.66 0.79 1 1.33 -#> 9 virgin… 50 Sepa… 1 0.46 0.86 0.28 6.59 -#> 10 virgin… 50 Sepa… 0.46 1 0.4 0.54 2.97 -#> 11 virgin… 50 Peta… 0.86 0.4 1 0.32 5.55 -#> 12 virgin… 50 Peta… 0.28 0.54 0.32 1 2.03 -#> # … with 1 more variable: sd <dbl>
Plot design
diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index 3fa0d792..0de6aca8 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -63,7 +63,7 @@ diff --git a/docs/reference/plot_design-1.png b/docs/reference/plot_design-1.png new file mode 100644 index 00000000..6ae7c014 Binary files /dev/null and b/docs/reference/plot_design-1.png differ diff --git a/docs/reference/plot_design-2.png b/docs/reference/plot_design-2.png new file mode 100644 index 00000000..6ae7c014 Binary files /dev/null and b/docs/reference/plot_design-2.png differ diff --git a/docs/reference/plot_design.html b/docs/reference/plot_design.html new file mode 100644 index 00000000..8a972a06 --- /dev/null +++ b/docs/reference/plot_design.html @@ -0,0 +1,188 @@ + + + + + + + + +#> # A tibble: 200 x 4 -#> sub_id B A1 A2 -#> <chr> <fct> <dbl> <dbl> -#> 1 S001 B1 0.387 -1.40 -#> 2 S002 B1 0.785 0.255 -#> 3 S003 B1 1.06 -2.44 -#> 4 S004 B1 0.796 -0.00557 -#> 5 S005 B1 1.76 0.622 -#> 6 S006 B1 0.691 1.15 -#> 7 S007 B1 0.559 -1.82 -#> 8 S008 B1 0.537 -0.247 -#> 9 S009 B1 -0.227 -0.244 -#> 10 S010 B1 -0.978 -0.283 -#> # … with 190 more rows+long2wide(df_long, "A", "B", "val", "sub_id")#> # A tibble: 200 x 4 +#> sub_id B A1 A2 +#> <chr> <fct> <dbl> <dbl> +#> 1 S001 B1 0.712 1.74 +#> 2 S002 B1 -0.662 -0.845 +#> 3 S003 B1 -0.291 -0.962 +#> 4 S004 B1 -0.198 1.02 +#> 5 S005 B1 1.20 -1.50 +#> 6 S006 B1 0.0398 -1.18 +#> 7 S007 B1 -0.687 0.630 +#> 8 S008 B1 -0.705 2.10 +#> 9 S009 B1 -0.991 -0.614 +#> 10 S010 B1 -1.14 -1.63 +#> # … with 190 more rows
plot_design.Rd
plot_design()
plots the specified within and between design
plot_design(design, id = "sub_id", dv = "val")+ +
design | +A list of design parameters created by check_design() or a data tbl (in long format) |
+
---|---|
id | +the column name(s) that identify a unit of analysis |
+
dv | +the column name that identifies the DV |
+
plot
+ + +++within <- list(time = c("day", "night")) +between <- list(pet = c("dog", "cat")) +check_design(within, between) %>% plot_design()+
#> A B C -#> 1 -1.711924939 -1.011599824 -1.32018668 -#> 2 0.887134792 0.043794457 0.99462051 -#> 3 0.748427556 0.410991509 1.01598343 -#> 4 -0.988547303 -1.612324193 0.10827445 -#> 5 0.250415810 1.967522573 1.12127447 -#> 6 1.012473136 1.329047164 0.46137529 -#> 7 0.290391321 -0.492076253 -1.07257786 -#> 8 -0.999779485 -2.143044059 -1.61909580 -#> 9 1.296369128 0.223297040 0.05172819 -#> 10 1.844675802 0.525323939 1.43792983 -#> 11 -0.594332509 1.134701125 -0.51513681 -#> 12 2.892055704 -0.024653246 -0.87388294 -#> 13 0.674912545 1.145791522 -0.16442269 -#> 14 0.114929596 0.751160451 0.22516804 -#> 15 -0.798672240 -0.534844472 -1.59558698 -#> 16 -1.031496700 0.049687627 -0.54144674 -#> 17 -0.004310488 -1.375989084 0.16455645 -#> 18 1.415566785 1.598106413 1.06560667 -#> 19 -1.642731803 -0.241490494 -0.33724621 -#> 20 0.910502722 -0.191788473 -0.98662517 -#> 21 -1.175150978 -0.479527388 0.14625695 -#> 22 0.305901881 0.761645013 -0.54205693 -#> 23 -0.367942472 -1.256019905 -0.12063644 -#> 24 0.892308000 0.193255995 1.16876289 -#> 25 2.538452134 2.240282666 2.04947504 -#> 26 -0.695068465 0.222697327 -1.11980217 -#> 27 0.512021718 0.508770162 0.57718656 -#> 28 -0.932274424 2.643562030 2.24879422 -#> 29 -0.585604074 0.622505249 -0.24917585 -#> 30 -1.355941412 -0.590585765 -0.21519908 -#> 31 -0.733846362 0.082328508 -0.42830930 -#> 32 1.264872249 0.715577491 0.12590367 -#> 33 -0.518786456 0.201122493 -0.92638734 -#> 34 -0.637506919 -1.122500780 -0.86513473 -#> 35 0.632266473 -0.010632207 1.05787745 -#> 36 1.104769095 0.406299810 -0.21379747 -#> 37 1.472185167 0.971669943 0.38215346 -#> 38 0.208642678 1.232615573 -0.26677942 -#> 39 0.194660642 -0.021702220 -0.36527459 -#> 40 1.781764439 0.408108369 1.86009067 -#> 41 2.042761937 -0.215878860 1.47377857 -#> 42 -0.490815530 -0.425984391 -0.68877135 -#> 43 1.655781000 -0.033659668 1.27356903 -#> 44 -0.025382344 0.905039301 -0.02548762 -#> 45 -0.665268785 -0.563017316 0.06761990 -#> 46 -0.276302646 0.608159422 0.33566043 -#> 47 0.484250987 1.126346311 1.25406657 -#> 48 1.282907646 0.720836758 0.47160057 -#> 49 -0.277030402 -1.021860386 -1.96611414 -#> 50 -0.819145743 -0.037232249 -0.04063296 -#> 51 -1.564663610 -0.636464908 -1.85042764 -#> 52 -0.898058218 0.284764624 -0.34268128 -#> 53 1.805225599 -0.408926161 0.83297444 -#> 54 1.365198223 1.113118376 1.19018362 -#> 55 0.216231182 -0.115908105 0.10565315 -#> 56 0.641593299 1.738105080 2.21714184 -#> 57 0.213674643 0.168441446 -0.31953324 -#> 58 0.253013272 0.862077906 -0.22789514 -#> 59 0.287070174 -1.951729555 -0.83911657 -#> 60 -0.481794003 0.239976721 0.61024139 -#> 61 0.025132801 -0.628056375 -1.53689844 -#> 62 -0.167673231 -0.101515541 0.75379782 -#> 63 -2.425362627 -0.498203692 -1.06272155 -#> 64 1.350643220 -0.486047718 0.95719724 -#> 65 -1.242626738 2.175710297 0.92752367 -#> 66 -0.338836433 1.113640640 -0.15518463 -#> 67 -0.026841819 0.966138768 0.37921477 -#> 68 -0.453608406 0.413598279 0.23549706 -#> 69 -0.493723033 -1.334332953 -0.84630857 -#> 70 -1.221646818 -1.238780109 0.72514498 -#> 71 0.321048652 1.743009432 -0.49620029 -#> 72 -0.527149031 1.184322665 1.00890307 -#> 73 0.070016525 1.224225492 0.62085618 -#> 74 1.134493406 2.219461421 1.58638671 -#> 75 1.504749960 0.614156332 1.09643083 -#> 76 0.446530671 0.052052719 0.61180283 -#> 77 1.818863849 -0.302817368 0.04494236 -#> 78 -0.791160513 0.179908256 0.79171348 -#> 79 -0.300914823 -0.253138072 -0.53330713 -#> 80 0.926355041 1.873512137 0.35236855 -#> 81 0.144573957 1.043953709 -0.49422615 -#> 82 -0.027810676 0.325938318 -1.58919459 -#> 83 -2.100930284 1.066836105 -0.83668769 -#> 84 -0.444333571 -0.715766312 -0.85121894 -#> 85 -0.968875193 -1.687613536 -0.79915130 -#> 86 0.959440062 -1.088246737 1.55349882 -#> 87 -0.345251762 -1.686853560 0.65311349 -#> 88 0.572082195 -0.813048594 -1.24514160 -#> 89 -1.365521552 -1.373149134 -1.59569125 -#> 90 1.176097394 2.119269863 1.42040520 -#> 91 1.221033387 -0.577310879 -0.56619463 -#> 92 0.108998277 0.648942202 -0.11418245 -#> 93 0.101151686 0.111384203 0.73298987 -#> 94 0.586259342 1.453725946 1.13935521 -#> 95 0.153452555 1.348353614 -0.27134221 -#> 96 0.235523130 0.480340620 -0.05456858 -#> 97 0.785445485 1.876836130 -0.04612489 -#> 98 -0.198978331 -0.525346365 -0.12181418 -#> 99 0.629380511 -0.357590811 0.51006913 -#> 100 -2.276017019 -0.001639159 -1.01436632#> A B C -#> 1 0.98053619 1.397345080 1.24702308 -#> 2 0.28494917 -0.929721452 0.11231993 -#> 3 -0.48926432 -0.317158657 0.91387543 -#> 4 0.62746163 0.690257228 -0.04676857 -#> 5 0.52497027 -0.006770402 -0.54982277 -#> 6 -0.08113113 -1.203695112 -0.38591526 -#> 7 0.10950230 -0.448304595 -0.72749899 -#> 8 -0.98054763 -1.413085775 0.44500300 -#> 9 -0.22717869 0.588496717 1.47955055 -#> 10 -0.08167748 0.129810359 0.62297867 -#> 11 -1.06794579 1.622348860 2.17266535 -#> 12 1.23713517 1.254934760 0.21802500 -#> 13 2.34268548 -0.127564780 -1.84686336 -#> 14 -0.79906111 -0.670100344 -0.78681222 -#> 15 1.14762821 0.425896059 -0.19353105 -#> 16 -0.68792927 0.746387469 1.17342419 -#> 17 -0.42239464 -2.279769415 -1.45252677 -#> 18 -0.71983873 -0.782993158 -0.48339888 -#> 19 -0.27644209 -0.078365574 -0.15548499 -#> 20 0.65702277 -2.167247198 -2.28768427 -#> 21 1.36346504 2.807540375 0.61058213 -#> 22 2.26453757 -0.107450280 -1.03851429 -#> 23 1.07057295 1.036447960 0.77105891 -#> 24 -0.75535093 0.189251094 1.72491550 -#> 25 -0.68100214 -0.665149580 -0.04357655 -#> 26 -0.47017350 -0.314580812 -0.27934568 -#> 27 0.73476477 1.147051694 0.19216533 -#> 28 -0.09149070 0.876867711 -0.08339957 -#> 29 -2.05839553 -1.187120062 -0.84369069 -#> 30 -0.62779679 0.680592120 0.13823150 -#> 31 0.82896856 0.492073064 -0.10702775 -#> 32 1.12230254 0.029101542 -0.69550195 -#> 33 1.41109327 -0.547954608 -1.55760838 -#> 34 -1.28998785 -0.644308963 0.45818445 -#> 35 -0.74524292 0.423205419 2.23457494 -#> 36 0.18163205 0.475178614 0.81660170 -#> 37 -1.29214617 0.507173875 0.60586872 -#> 38 -0.52453660 -0.422831247 0.14219949 -#> 39 2.71082498 1.025301778 -0.77900169 -#> 40 0.67234061 -0.927892656 -0.94160161 -#> 41 -0.22932465 -0.452949466 -0.75393801 -#> 42 0.79662820 0.012013809 -0.66456985 -#> 43 -1.48598921 -1.485862845 -0.34075299 -#> 44 -2.73794234 -0.333565773 1.35801078 -#> 45 1.04730267 -0.239862856 -0.94911295 -#> 46 0.79570220 0.409234356 -0.02512850 -#> 47 -0.29797799 -0.960151155 0.32858669 -#> 48 1.32398457 0.086940658 -0.84502893 -#> 49 0.70645034 0.763352966 0.66553042 -#> 50 -1.19011584 -0.898273386 0.01265418 -#> 51 0.17313328 0.375553597 -0.01675357 -#> 52 1.04061188 -0.219130525 -0.77337525 -#> 53 -0.43883826 -0.042922039 1.27360295 -#> 54 0.67987637 -1.058120498 -0.27502560 -#> 55 -0.51468288 0.062507127 0.76999444 -#> 56 -0.80241295 -0.945210621 0.34889021 -#> 57 -0.47060134 -1.268959331 0.70686003 -#> 58 2.49959376 0.682354301 -1.46377249 -#> 59 -0.76711289 -0.641906992 0.26363487 -#> 60 0.84037060 -0.130252667 -0.61136080 -#> 61 -0.47759972 0.405378724 0.06637905 -#> 62 -1.35795459 0.303024258 1.33414293 -#> 63 -0.86120089 -1.445283701 0.98588190 -#> 64 0.65405904 -1.262137582 -1.45782179 -#> 65 -1.52487511 -1.185720620 -0.29528001 -#> 66 -0.60310623 0.543202595 0.16109147 -#> 67 -1.34640940 0.111464903 0.03001872 -#> 68 -1.20726090 -0.211677096 0.84891723 -#> 69 -0.07838011 0.191885581 0.98564804 -#> 70 1.13262307 0.785543693 -0.06059885 -#> 71 1.36490199 -0.252005899 -2.00968693 -#> 72 1.18092139 -0.345183489 -0.80804496 -#> 73 -1.50057211 -0.143484529 0.56351319 -#> 74 -0.67605220 -0.161655297 0.70612018 -#> 75 -0.39630979 -0.711680593 -0.01193046 -#> 76 -1.06729240 0.790110596 0.42953674 -#> 77 0.25135374 0.004217116 -1.46584325 -#> 78 -0.62606452 -0.500831364 0.35233621 -#> 79 0.22130814 -1.054521838 -0.13425086 -#> 80 -0.82249462 -0.106502250 1.12587401 -#> 81 1.13659660 0.694685870 -0.63335312 -#> 82 0.63912932 -0.346001998 -0.15632373 -#> 83 0.50735668 -0.121686372 -0.35290927 -#> 84 0.95787156 0.663581444 -0.85623386 -#> 85 -0.91227314 -1.085103286 0.84931769 -#> 86 -0.23904032 0.820166860 0.16160248 -#> 87 -0.71341295 -0.149361316 0.56590330 -#> 88 1.64368977 -1.175172449 -2.12371033 -#> 89 -0.35317370 0.697507425 -0.12301334 -#> 90 -1.24671366 -0.243868992 1.74687093 -#> 91 -0.64148189 0.722090091 1.47996273 -#> 92 0.22026898 1.174067582 1.19864762 -#> 93 -0.88325604 0.271478223 0.35463827 -#> 94 0.07313435 1.405022266 1.00772946 -#> 95 -1.47150701 0.560249257 1.03483886 -#> 96 -1.10044697 -1.187067944 0.66307881 -#> 97 -2.23696083 0.102519789 2.21376158 -#> 98 -0.92624102 -1.158465566 0.37674556 -#> 99 -1.39758231 0.256387690 1.30028559 -#> 100 -0.21576305 -0.512530549 -0.64474625+diff --git a/docs/reference/select_num_grp.html b/docs/reference/select_num_grp.html index 6541896e..2f6bb5b8 100644 --- a/docs/reference/select_num_grp.html +++ b/docs/reference/select_num_grp.html @@ -63,7 +63,7 @@ @@ -151,21 +151,21 @@#> A B C +#> 1 0.580063420 -0.09872452 1.0784038131 +#> 2 0.090745757 -2.21205847 -1.1273322465 +#> 3 -0.853981885 -1.05175966 -0.1363566233 +#> 4 -1.211615762 -0.80127979 -0.9921388410 +#> 5 0.192619570 -0.83783332 -0.0197866182 +#> 6 -0.114386798 0.66023232 0.3335085124 +#> 7 -0.062983007 -0.27383834 0.5704329171 +#> 8 0.193590660 0.14185678 0.1785742297 +#> 9 -0.340948097 -1.43084148 -2.0317941800 +#> 10 2.133504111 -0.93541542 -0.6585662765 +#> 11 0.396551231 0.52315754 -1.0162089235 +#> 12 -0.384779171 0.38412907 -0.8367164291 +#> 13 0.561300727 -0.28195229 -0.9540677145 +#> 14 0.675929362 -0.93428998 -0.0396729591 +#> 15 0.283146696 -2.36093571 -0.4917625244 +#> 16 0.280137890 0.67161321 -0.8344114511 +#> 17 -0.526655044 0.44061761 -0.0237941410 +#> 18 0.408507595 1.26118948 0.2582611048 +#> 19 -0.388734127 -0.35053585 0.5105104491 +#> 20 -0.244792403 -0.71618395 1.4115771521 +#> 21 -1.106792267 0.24557872 -1.8149257666 +#> 22 -0.943906760 0.60176480 0.1351054811 +#> 23 -0.267375172 -0.29709120 0.1000263582 +#> 24 0.452204594 -1.17153794 0.5214464384 +#> 25 0.536259704 -1.09615222 -0.5867834183 +#> 26 -0.236333920 0.49410299 0.0880169640 +#> 27 0.738830878 -0.03269877 -0.0777189754 +#> 28 -0.376182790 1.04535590 -1.1190239099 +#> 29 -0.405648929 0.69822409 1.5864914799 +#> 30 -1.160958357 -1.35009209 -0.9999216075 +#> 31 1.006528656 0.61391014 0.3346503048 +#> 32 -1.067981697 -0.75249566 -1.1806269747 +#> 33 -0.357735257 -0.50998132 -0.9337983791 +#> 34 0.788906573 -0.46545444 -0.4438848537 +#> 35 -0.398840231 -0.91834381 -0.6787544321 +#> 36 1.375238390 0.31725327 2.3153530303 +#> 37 1.309298537 1.06693175 -0.0002758011 +#> 38 -0.530013223 0.71744745 0.7425554627 +#> 39 1.474483534 2.06301787 0.8343343677 +#> 40 -1.418679613 0.55912804 0.0881185330 +#> 41 1.987764609 -1.66214704 0.3601230636 +#> 42 2.552996783 1.74737931 1.3149925548 +#> 43 0.524412448 -0.01102079 -0.4011135037 +#> 44 -0.235328699 -0.60681908 -0.6471093657 +#> 45 -0.552260875 0.48935906 -0.4639006189 +#> 46 -0.808378301 1.56206858 0.4561830091 +#> 47 0.376584113 0.17787723 0.3772892838 +#> 48 -1.523135326 -1.12397467 -0.7134540706 +#> 49 0.184684633 -0.30179709 -0.3685977391 +#> 50 0.708403805 0.89554929 1.5859329703 +#> 51 0.254379268 0.43257257 0.0637306254 +#> 52 1.570630317 -1.16270365 0.7844504392 +#> 53 0.744131290 -0.76748954 -1.5993367811 +#> 54 1.131117657 -0.21915384 -0.5733556287 +#> 55 -0.664541255 0.55462340 -1.9073133381 +#> 56 -1.232069852 -0.76910659 -1.4118222935 +#> 57 0.392813673 0.94396233 -0.4308654690 +#> 58 -0.144178008 -0.64698290 -0.6334769218 +#> 59 1.164475659 1.45358400 0.9452965010 +#> 60 -0.233225524 -0.68819951 -0.4350951565 +#> 61 0.062137521 0.31379011 0.7014771458 +#> 62 0.637040390 0.58403290 -0.1763327235 +#> 63 -0.270598875 0.15623892 1.0077853602 +#> 64 -1.481668036 -1.54096019 -2.0061784034 +#> 65 -0.919249237 -2.08932046 -0.4806280284 +#> 66 0.825289240 -0.24405615 0.2990468946 +#> 67 -1.216081227 -0.96032094 -0.0007913805 +#> 68 0.206769111 0.24427677 0.0626262792 +#> 69 -1.048041344 -1.13750948 -2.2996884331 +#> 70 1.527935152 0.97355428 1.7036046674 +#> 71 0.250693735 -0.41953515 -0.1767846545 +#> 72 -1.293875018 1.76704580 0.9987815774 +#> 73 0.390036316 1.64125076 0.5327712176 +#> 74 -1.469682995 -1.17649262 -0.2694275683 +#> 75 -0.887855165 -0.01672167 -1.2938965114 +#> 76 -1.090398999 -0.88722919 -0.8025775367 +#> 77 -0.736544396 -0.52134426 -0.2607690775 +#> 78 -0.420887465 -0.74300358 -0.1066756230 +#> 79 1.318045818 0.06358653 0.5941506545 +#> 80 -0.416977414 -0.73062603 1.2852225469 +#> 81 0.318201763 0.27278899 -0.4486797764 +#> 82 -0.254429189 0.34508490 0.6871103199 +#> 83 1.934886554 -1.00513721 0.2076976831 +#> 84 -2.219295612 -0.31100630 -0.6100749433 +#> 85 -0.178935745 -1.18453086 -0.4916501471 +#> 86 0.800414923 -0.87700750 -0.7008907125 +#> 87 0.083590913 -2.54822932 -1.3076891318 +#> 88 0.810749904 1.74466727 2.3461962818 +#> 89 -0.446075261 1.02050310 -0.1750381996 +#> 90 0.748926181 -1.34145000 -0.7647587615 +#> 91 0.996404056 0.44301890 0.4587844649 +#> 92 2.093318974 0.42018888 1.1995588949 +#> 93 -1.929648067 0.54120179 -1.4522228536 +#> 94 -1.846602547 -1.01815754 -0.7388437472 +#> 95 -0.009962785 0.96157126 1.5401153622 +#> 96 -0.669352258 0.61491480 -1.2687851047 +#> 97 -1.241527096 -1.03666393 -1.1485718522 +#> 98 -0.595984914 0.39510322 1.0143729066 +#> 99 0.042787189 -0.01241021 -0.5676048913 +#> 100 1.578485546 0.94305738 0.4515601245#> A B C +#> 1 0.484658341 -0.742205822 -0.4449783380 +#> 2 1.186786630 -1.000544878 -0.9497220323 +#> 3 -0.381113323 -0.644041064 -0.6810782917 +#> 4 -1.339846455 0.517809498 1.2797721443 +#> 5 -0.181445384 -0.285510466 -0.7970645955 +#> 6 -0.242856053 -0.690225584 0.2714375811 +#> 7 -1.407509023 0.914543179 1.5745573922 +#> 8 -0.608448700 1.085903958 0.6950162330 +#> 9 1.006665710 0.230597685 -0.5005835875 +#> 10 2.688694138 0.023284165 -1.0438745075 +#> 11 0.620829156 -0.209781278 -0.3128392194 +#> 12 0.489134064 0.002199792 -0.9675840914 +#> 13 -0.484478368 0.254056963 0.6661222175 +#> 14 -0.606086667 1.105266125 0.1869479128 +#> 15 -0.356848057 -0.145414572 1.0999266440 +#> 16 -0.207898361 -1.005676610 -0.3997856883 +#> 17 0.696548011 -0.724568456 -1.1672952581 +#> 18 -0.128278497 -0.133843063 -1.0397383583 +#> 19 -0.668768791 0.413550026 0.6493829976 +#> 20 0.639193185 0.466345909 0.2680866712 +#> 21 1.198673387 -0.831190728 -1.3807877910 +#> 22 -2.233381972 -1.364908356 0.6418456875 +#> 23 -0.006388825 0.128843689 -0.0187768989 +#> 24 -0.327426061 -0.336877882 0.4006878327 +#> 25 -0.901291393 0.323884749 0.9662414449 +#> 26 -1.155951524 1.086363905 1.1052114866 +#> 27 1.251580671 0.919370611 0.1225804313 +#> 28 -0.069191573 -0.396917498 -0.7994340803 +#> 29 -0.280314246 -1.215826046 -0.2231116973 +#> 30 1.750322871 0.857307988 -0.0007566503 +#> 31 0.423765513 -1.626792490 -0.7358762655 +#> 32 0.882765629 -0.499647999 -0.7955647900 +#> 33 -0.644431348 -0.853866273 -1.0201752962 +#> 34 -0.596586156 -1.011250991 0.1999263842 +#> 35 -1.850151884 0.217921810 1.2229191838 +#> 36 -0.258891740 -0.059479010 -0.0749215286 +#> 37 1.261662599 0.765095233 -0.8528689506 +#> 38 0.663405728 0.132448812 -1.1795552736 +#> 39 -0.888862937 -1.257320157 -0.6709252565 +#> 40 -1.429992304 -0.121120191 0.1786727354 +#> 41 0.827544340 -0.360732604 -1.3953480577 +#> 42 -0.778549707 1.456603829 0.1303537042 +#> 43 0.101137027 -1.108538951 -0.7668516668 +#> 44 -2.083907549 -1.664642951 0.6758047495 +#> 45 0.784731572 -0.357857436 -1.2570525548 +#> 46 -0.396700814 0.059989238 -0.2490777923 +#> 47 -0.142656675 0.794573153 -0.0222581321 +#> 48 0.883357520 -0.086309086 0.0991830449 +#> 49 -1.275348327 -0.236850668 0.4418877639 +#> 50 -0.063148286 1.335536045 0.7004060631 +#> 51 -0.189248763 2.493607894 1.3344436428 +#> 52 -0.379607355 1.199938987 1.8268748851 +#> 53 2.136125617 0.784385418 0.8771598668 +#> 54 -0.133719304 1.254436644 1.8660023148 +#> 55 0.055052583 -0.233683471 -2.0902631686 +#> 56 0.863391065 0.347070631 0.6429265108 +#> 57 1.266501199 1.526597049 0.5495661158 +#> 58 0.110814965 -0.709871332 -0.3375972250 +#> 59 2.873482195 1.333414640 -1.7372521577 +#> 60 -0.121849296 2.057985608 1.0459021110 +#> 61 -1.969534427 -1.061842864 1.2104195769 +#> 62 0.954160571 0.078773527 -0.4458596260 +#> 63 -0.450664181 -0.381147771 -0.9290400544 +#> 64 0.659332635 1.078532099 -0.4631530029 +#> 65 1.753360709 0.406460694 -0.1594744993 +#> 66 0.356176961 -0.182342767 -0.0863782273 +#> 67 -0.378471770 0.786100705 0.6331283834 +#> 68 -0.544572435 2.104225395 2.6224708911 +#> 69 -0.197379421 0.125805280 0.2559255452 +#> 70 -0.303661009 -0.706925285 -1.2438850305 +#> 71 -0.159819774 -1.354128104 -0.5614660445 +#> 72 -0.312157889 -0.090535005 0.6279715098 +#> 73 -0.268737731 -2.137525108 -0.0414486934 +#> 74 0.100258193 -0.170363547 -1.4314265220 +#> 75 1.132417516 -0.083062632 -1.0480427931 +#> 76 0.786918873 0.043642424 -1.0352274354 +#> 77 -0.001441801 0.957098100 0.5364156134 +#> 78 0.874144243 -1.898837326 -1.7762561578 +#> 79 0.075263017 1.998466596 1.6697597415 +#> 80 -0.522652730 -1.209063287 0.1022117196 +#> 81 0.213258376 0.847526255 0.3208845313 +#> 82 -0.136484929 -0.809384890 -0.7026234504 +#> 83 0.059288270 -0.600432078 -0.7101281773 +#> 84 0.737873426 1.018864267 0.0180777342 +#> 85 1.076905586 1.299179888 1.4502742459 +#> 86 1.069959862 0.644484824 -1.7847490104 +#> 87 0.455682746 0.077335425 0.1528263410 +#> 88 -1.552552000 -1.605602164 -0.2905896920 +#> 89 -0.677481263 -0.086980016 0.7011170010 +#> 90 -0.025159957 -0.069020087 -0.2286867488 +#> 91 0.333055133 0.345835151 0.0177301819 +#> 92 -1.188859716 -0.693241686 1.1911399347 +#> 93 0.272511523 0.499988896 -0.1223121118 +#> 94 -0.831075700 -0.846499224 0.5899186297 +#> 95 0.702452657 -0.048435204 -1.0755290853 +#> 96 0.553022585 -0.898320302 -0.6642299409 +#> 97 -0.076327485 -0.698772198 -0.2438553542 +#> 98 -0.831051326 -0.887911590 -0.4662089586 +#> 99 -0.302220904 1.710761438 1.4132701210 +#> 100 0.728187681 -1.090645135 -2.2160014589Value
Examples
-@@ -127,7 +127,7 @@select_num_grp(iris, "Species")#> # A tibble: 150 x 5 -#> # Groups: Species [3] ++#> <fct> <dbl> <dbl> <dbl> <dbl> +#> 1 setosa 5.1 3.5 1.4 0.2 +#> 2 setosa 4.9 3 1.4 0.2 +#> 3 setosa 4.7 3.2 1.3 0.2 +#> 4 setosa 4.6 3.1 1.5 0.2 +#> 5 setosa 5 3.6 1.4 0.2 +#> 6 setosa 5.4 3.9 1.7 0.4 +#> 7 setosa 4.6 3.4 1.4 0.3 +#> 8 setosa 5 3.4 1.5 0.2 +#> 9 setosa 4.4 2.9 1.4 0.2 +#> 10 setosa 4.9 3.1 1.5 0.1 +#> # … with 140 more rowsselect_num_grp(iris, "Species")#> # A tibble: 150 x 5 +#> # Groups: Species [3] #> Species Sepal.Length Sepal.Width Petal.Length Petal.Width -#> <fct> <dbl> <dbl> <dbl> <dbl> -#> 1 setosa 5.1 3.5 1.4 0.2 -#> 2 setosa 4.9 3 1.4 0.2 -#> 3 setosa 4.7 3.2 1.3 0.2 -#> 4 setosa 4.6 3.1 1.5 0.2 -#> 5 setosa 5 3.6 1.4 0.2 -#> 6 setosa 5.4 3.9 1.7 0.4 -#> 7 setosa 4.6 3.4 1.4 0.3 -#> 8 setosa 5 3.4 1.5 0.2 -#> 9 setosa 4.4 2.9 1.4 0.2 -#> 10 setosa 4.9 3.1 1.5 0.1 -#> # … with 140 more rowsSimulate Data from Design
sim_design(within = list(), between = list(), n = 100, mu = 0, - sd = 1, r = 0, empirical = FALSE, long = FALSE)+ sd = 1, r = 0, empirical = FALSE, long = FALSE, plot = FALSE)
long | Whether the returned tbl is in wide (default = FALSE) or long (TRUE) format |
+
---|---|
plot | +whether to show a plot of the design |
+
+sim_mixed_df(faceratings, 10, 10, "rating", "rater_id", "face_id")#> sub_id item_id sub_i item_i dv -#> 1 1 1 0.15336871 0.1152507 3.4263347 -#> 2 2 1 -0.07546968 0.1152507 2.6552210 -#> 3 3 1 -0.09464565 0.1152507 2.5473771 -#> 4 4 1 0.13680669 0.1152507 4.5736075 -#> 5 5 1 0.46710613 0.1152507 4.6470300 -#> 6 6 1 0.71713231 0.1152507 5.0470723 -#> 7 7 1 -0.16377959 0.1152507 3.0286129 -#> 8 8 1 -0.03648029 0.1152507 3.0203508 -#> 9 9 1 -0.44490238 0.1152507 2.4007496 -#> 10 10 1 -0.50294582 0.1152507 1.4482325 -#> 11 1 2 0.15336871 0.9694343 4.2646276 -#> 12 2 2 -0.07546968 0.9694343 3.5117228 -#> 13 3 2 -0.09464565 0.9694343 1.9205807 -#> 14 4 2 0.13680669 0.9694343 3.3332175 -#> 15 5 2 0.46710613 0.9694343 4.1037056 -#> 16 6 2 0.71713231 0.9694343 4.8340290 -#> 17 7 2 -0.16377959 0.9694343 4.3931885 -#> 18 8 2 -0.03648029 0.9694343 3.5224828 -#> 19 9 2 -0.44490238 0.9694343 2.7403387 -#> 20 10 2 -0.50294582 0.9694343 4.9209943 -#> 21 1 3 0.15336871 -0.1809222 2.3955324 -#> 22 2 3 -0.07546968 -0.1809222 5.0649247 -#> 23 3 3 -0.09464565 -0.1809222 3.0032075 -#> 24 4 3 0.13680669 -0.1809222 2.4135067 -#> 25 5 3 0.46710613 -0.1809222 4.5656069 -#> 26 6 3 0.71713231 -0.1809222 2.8650467 -#> 27 7 3 -0.16377959 -0.1809222 3.6126806 -#> 28 8 3 -0.03648029 -0.1809222 0.9722492 -#> 29 9 3 -0.44490238 -0.1809222 0.6125408 -#> 30 10 3 -0.50294582 -0.1809222 3.8909402 -#> 31 1 4 0.15336871 1.0979794 5.9448229 -#> 32 2 4 -0.07546968 1.0979794 3.9574235 -#> 33 3 4 -0.09464565 1.0979794 4.8079004 -#> 34 4 4 0.13680669 1.0979794 5.0826263 -#> 35 5 4 0.46710613 1.0979794 3.3817108 -#> 36 6 4 0.71713231 1.0979794 3.2445244 -#> 37 7 4 -0.16377959 1.0979794 4.2746244 -#> 38 8 4 -0.03648029 1.0979794 4.7967650 -#> 39 9 4 -0.44490238 1.0979794 4.3737837 -#> 40 10 4 -0.50294582 1.0979794 4.2923638 -#> 41 1 5 0.15336871 0.2255086 5.9170173 -#> 42 2 5 -0.07546968 0.2255086 2.7538325 -#> 43 3 5 -0.09464565 0.2255086 3.1842397 -#> 44 4 5 0.13680669 0.2255086 4.2260520 -#> 45 5 5 0.46710613 0.2255086 1.5543152 -#> 46 6 5 0.71713231 0.2255086 3.9556215 -#> 47 7 5 -0.16377959 0.2255086 3.8447343 -#> 48 8 5 -0.03648029 0.2255086 4.5385200 -#> 49 9 5 -0.44490238 0.2255086 2.6456965 -#> 50 10 5 -0.50294582 0.2255086 2.2025837 -#> 51 1 6 0.15336871 -0.5688417 3.5177725 -#> 52 2 6 -0.07546968 -0.5688417 2.9838297 -#> 53 3 6 -0.09464565 -0.5688417 3.5923231 -#> 54 4 6 0.13680669 -0.5688417 3.1022826 -#> 55 5 6 0.46710613 -0.5688417 2.7535176 -#> 56 6 6 0.71713231 -0.5688417 5.4940446 -#> 57 7 6 -0.16377959 -0.5688417 2.5234260 -#> 58 8 6 -0.03648029 -0.5688417 0.3511046 -#> 59 9 6 -0.44490238 -0.5688417 1.8498874 -#> 60 10 6 -0.50294582 -0.5688417 3.5379786 -#> 61 1 7 0.15336871 -0.1003512 4.2409599 -#> 62 2 7 -0.07546968 -0.1003512 3.5556705 -#> 63 3 7 -0.09464565 -0.1003512 2.6899611 -#> 64 4 7 0.13680669 -0.1003512 2.0439883 -#> 65 5 7 0.46710613 -0.1003512 5.0354057 -#> 66 6 7 0.71713231 -0.1003512 3.5521496 -#> 67 7 7 -0.16377959 -0.1003512 2.3525066 -#> 68 8 7 -0.03648029 -0.1003512 3.5415480 -#> 69 9 7 -0.44490238 -0.1003512 4.1344729 -#> 70 10 7 -0.50294582 -0.1003512 2.3269392 -#> 71 1 8 0.15336871 1.6989795 6.4250556 -#> 72 2 8 -0.07546968 1.6989795 5.7450023 -#> 73 3 8 -0.09464565 1.6989795 3.8872425 -#> 74 4 8 0.13680669 1.6989795 4.5973502 -#> 75 5 8 0.46710613 1.6989795 5.7349937 -#> 76 6 8 0.71713231 1.6989795 2.6852695 -#> 77 7 8 -0.16377959 1.6989795 3.7919020 -#> 78 8 8 -0.03648029 1.6989795 4.7810577 -#> 79 9 8 -0.44490238 1.6989795 5.1999969 -#> 80 10 8 -0.50294582 1.6989795 5.4375538 -#> 81 1 9 0.15336871 1.2452224 5.3180720 -#> 82 2 9 -0.07546968 1.2452224 2.7003936 -#> 83 3 9 -0.09464565 1.2452224 4.3759073 -#> 84 4 9 0.13680669 1.2452224 6.5338902 -#> 85 5 9 0.46710613 1.2452224 3.8544295 -#> 86 6 9 0.71713231 1.2452224 5.2503336 -#> 87 7 9 -0.16377959 1.2452224 4.6527757 -#> 88 8 9 -0.03648029 1.2452224 3.6883031 -#> 89 9 9 -0.44490238 1.2452224 2.8378979 -#> 90 10 9 -0.50294582 1.2452224 4.8626384 -#> 91 1 10 0.15336871 -0.2064970 4.7460439 -#> 92 2 10 -0.07546968 -0.2064970 1.8389187 -#> 93 3 10 -0.09464565 -0.2064970 1.3021962 -#> 94 4 10 0.13680669 -0.2064970 2.4226626 -#> 95 5 10 0.46710613 -0.2064970 3.0711292 -#> 96 6 10 0.71713231 -0.2064970 2.2198113 -#> 97 7 10 -0.16377959 -0.2064970 0.9575364 -#> 98 8 10 -0.03648029 -0.2064970 2.6135275 -#> 99 9 10 -0.44490238 -0.2064970 1.2924662 -#> 100 10 10 -0.50294582 -0.2064970 0.8947152
@@ -407,7 +407,356 @@sim_mixed_df(faceratings, 10, 10, "rating", "rater_id", "face_id")#> sub_id item_id sub_i item_i dv +#> 1 1 1 -0.2396229 -0.6240398122 2.8518221 +#> 2 2 1 -0.5442409 -0.6240398122 1.9668874 +#> 3 3 1 -1.0690789 -0.6240398122 -0.2629545 +#> 4 4 1 -0.1472031 -0.6240398122 2.7428086 +#> 5 5 1 -1.8498327 -0.6240398122 1.9288361 +#> 6 6 1 0.4872866 -0.6240398122 0.7987672 +#> 7 7 1 0.0527697 -0.6240398122 2.7039147 +#> 8 8 1 1.4916886 -0.6240398122 5.0352024 +#> 9 9 1 1.1627588 -0.6240398122 4.0272131 +#> 10 10 1 1.3705433 -0.6240398122 1.8661317 +#> 11 1 2 -0.2396229 0.0737720044 5.7190067 +#> 12 2 2 -0.5442409 0.0737720044 2.5149279 +#> 13 3 2 -1.0690789 0.0737720044 -0.4307355 +#> 14 4 2 -0.1472031 0.0737720044 4.9436124 +#> 15 5 2 -1.8498327 0.0737720044 1.7851634 +#> 16 6 2 0.4872866 0.0737720044 3.7499332 +#> 17 7 2 0.0527697 0.0737720044 3.7508227 +#> 18 8 2 1.4916886 0.0737720044 5.3318171 +#> 19 9 2 1.1627588 0.0737720044 0.6610708 +#> 20 10 2 1.3705433 0.0737720044 5.4186885 +#> 21 1 3 -0.2396229 0.7077325203 5.0765159 +#> 22 2 3 -0.5442409 0.7077325203 3.0633821 +#> 23 3 3 -1.0690789 0.7077325203 4.0995844 +#> 24 4 3 -0.1472031 0.7077325203 4.8202937 +#> 25 5 3 -1.8498327 0.7077325203 0.8647338 +#> 26 6 3 0.4872866 0.7077325203 4.0022090 +#> 27 7 3 0.0527697 0.7077325203 4.7845643 +#> 28 8 3 1.4916886 0.7077325203 4.9096337 +#> 29 9 3 1.1627588 0.7077325203 5.5897579 +#> 30 10 3 1.3705433 0.7077325203 6.4079320 +#> 31 1 4 -0.2396229 0.3657847830 2.0720024 +#> 32 2 4 -0.5442409 0.3657847830 4.3231517 +#> 33 3 4 -1.0690789 0.3657847830 1.6225195 +#> 34 4 4 -0.1472031 0.3657847830 1.8747657 +#> 35 5 4 -1.8498327 0.3657847830 0.9092096 +#> 36 6 4 0.4872866 0.3657847830 2.0484583 +#> 37 7 4 0.0527697 0.3657847830 3.7233531 +#> 38 8 4 1.4916886 0.3657847830 3.3307094 +#> 39 9 4 1.1627588 0.3657847830 5.3892575 +#> 40 10 4 1.3705433 0.3657847830 4.0696969 +#> 41 1 5 -0.2396229 -0.3051109814 -0.2706484 +#> 42 2 5 -0.5442409 -0.3051109814 3.3070643 +#> 43 3 5 -1.0690789 -0.3051109814 2.4620409 +#> 44 4 5 -0.1472031 -0.3051109814 3.4348493 +#> 45 5 5 -1.8498327 -0.3051109814 -0.8413550 +#> 46 6 5 0.4872866 -0.3051109814 1.9528294 +#> 47 7 5 0.0527697 -0.3051109814 3.2404056 +#> 48 8 5 1.4916886 -0.3051109814 5.3511790 +#> 49 9 5 1.1627588 -0.3051109814 4.9246782 +#> 50 10 5 1.3705433 -0.3051109814 4.8392120 +#> 51 1 6 -0.2396229 0.3314753477 2.8604816 +#> 52 2 6 -0.5442409 0.3314753477 1.7884178 +#> 53 3 6 -1.0690789 0.3314753477 1.2994108 +#> 54 4 6 -0.1472031 0.3314753477 3.1696075 +#> 55 5 6 -1.8498327 0.3314753477 0.5555800 +#> 56 6 6 0.4872866 0.3314753477 6.2175933 +#> 57 7 6 0.0527697 0.3314753477 5.0767993 +#> 58 8 6 1.4916886 0.3314753477 2.7947075 +#> 59 9 6 1.1627588 0.3314753477 5.5094497 +#> 60 10 6 1.3705433 0.3314753477 4.2839022 +#> 61 1 7 -0.2396229 0.6568782867 2.0689045 +#> 62 2 7 -0.5442409 0.6568782867 4.4199572 +#> 63 3 7 -1.0690789 0.6568782867 3.7038534 +#> 64 4 7 -0.1472031 0.6568782867 2.3687959 +#> 65 5 7 -1.8498327 0.6568782867 0.6508695 +#> 66 6 7 0.4872866 0.6568782867 2.5024103 +#> 67 7 7 0.0527697 0.6568782867 2.2378004 +#> 68 8 7 1.4916886 0.6568782867 3.7602979 +#> 69 9 7 1.1627588 0.6568782867 1.6174663 +#> 70 10 7 1.3705433 0.6568782867 6.2707761 +#> 71 1 8 -0.2396229 -0.1315365784 2.6521274 +#> 72 2 8 -0.5442409 -0.1315365784 2.5200856 +#> 73 3 8 -1.0690789 -0.1315365784 0.2040451 +#> 74 4 8 -0.1472031 -0.1315365784 4.0073279 +#> 75 5 8 -1.8498327 -0.1315365784 -0.3466308 +#> 76 6 8 0.4872866 -0.1315365784 2.1630615 +#> 77 7 8 0.0527697 -0.1315365784 1.5184225 +#> 78 8 8 1.4916886 -0.1315365784 4.1895499 +#> 79 9 8 1.1627588 -0.1315365784 3.3068711 +#> 80 10 8 1.3705433 -0.1315365784 3.5817560 +#> 81 1 9 -0.2396229 -0.0006109263 2.6098816 +#> 82 2 9 -0.5442409 -0.0006109263 1.2921410 +#> 83 3 9 -1.0690789 -0.0006109263 2.5477599 +#> 84 4 9 -0.1472031 -0.0006109263 4.3883662 +#> 85 5 9 -1.8498327 -0.0006109263 -0.5593484 +#> 86 6 9 0.4872866 -0.0006109263 5.7547464 +#> 87 7 9 0.0527697 -0.0006109263 1.2249057 +#> 88 8 9 1.4916886 -0.0006109263 5.4460634 +#> 89 9 9 1.1627588 -0.0006109263 3.7680685 +#> 90 10 9 1.3705433 -0.0006109263 6.3987326 +#> 91 1 10 -0.2396229 0.6643744909 4.5724435 +#> 92 2 10 -0.5442409 0.6643744909 1.5404019 +#> 93 3 10 -1.0690789 0.6643744909 -0.4066272 +#> 94 4 10 -0.1472031 0.6643744909 3.4523366 +#> 95 5 10 -1.8498327 0.6643744909 0.7951289 +#> 96 6 10 0.4872866 0.6643744909 4.9414845 +#> 97 7 10 0.0527697 0.6643744909 5.6692058 +#> 98 8 10 1.4916886 0.6643744909 6.1173654 +#> 99 9 10 1.1627588 0.6643744909 5.0124822 +#> 100 10 10 1.3705433 0.6643744909 5.0033603