Title: | Simulate a Data Frame Mirroring an Input and Produce Shareable Simulation Code |
Version: | 2.1.0 |
Maintainer: | Jacob Patterson-Stein <jacobpstein@gmail.com> |
Description: | The 'dfmirroR' package allows users to input a data frame, simulate some number of observations based on specified columns of that data frame, and then outputs a string that contains the code to re-create the simulation. The goal is to both provide workable test data sets and provide users with the information they need to set up reproducible examples with team members. This package was created out of a need to share examples in cases where data are private and where a full data frame is not needed for testing or coordinating. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
Depends: | R (≥ 2.10) |
RoxygenNote: | 7.2.3 |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
Imports: | fitdistrplus, stats, MASS, e1071 |
URL: | https://github.com/jacobpstein/dfmirroR |
BugReports: | https://github.com/jacobpstein/dfmirroR/issues |
NeedsCompilation: | no |
Packaged: | 2024-01-26 20:33:55 UTC; jacobpstein |
Author: | Jacob Patterson-Stein [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2024-01-26 20:50:02 UTC |
Simulate data that mirrors a data frame and output code to re-create the simulation
Description
Simulate data that mirrors a data frame and output code to re-create the simulation
Usage
simulate_dataframe(
input_df,
num_obs = 1,
columns_to_simulate = colnames(input_df)
)
Arguments
input_df |
A data frame. |
num_obs |
A numeric value specifying how many observations (i.e., rows) to simulate. |
columns_to_simulate |
One or more columns from the |
Value
A list with
-
simulated_df
a data frame object containing a simulated mirror of the input df where each specified column has the same mean and standard deviation as the input df -
code
a string vector that can be run in conjunction withcat()
to output easily shareable code to recreatesimulated_df
Examples
# # Run the function and create an object called `mirrored_df`
mirrored_df <- simulate_dataframe(mtcars, num_obs = 10, columns_to_simulate = c("mpg", "wt"))
# Print the mirrored data frame
print(mirrored_df$simulated_df)
# Output code to create the mirrored data frame for asking
# questions or supporting other reproducible tasks
cat(mirrored_df$code)