Faux
Documentation for Faux.
Faux.rep_len
— Methodrep_len(x, len)
Repeat a value or vector to create a vector of specified length
Arguments
x
: The value or vector to repeatlen
: The length of the resulting vector
Examples
julia> rep_len(1, 3)
[1, 1, 1]
julia> rep_len(1:2, 3)
[1, 2, 1]
julia> rep_len([1,2,3], 2)
[1,2]
Faux.rnorm_multi
— Methodrnorm_multi(n = 100, vars = 1, mu = 0, sd = 1, r = 0,
varnames = "X",
empirical = false,
as_matrix = false)
Make normally distributed vectors with specified relationships.
Arguments
- @
n
: the number of samples required - @
vars
: the number of variables to return - @
mu
: a vector giving the means of the variables (numeric vector of length 1 or vars) - @
sd
: the standard deviations of the variables (numeric vector of length 1 or vars) - @
r
: the correlations among the variables (can be a single number, varsvars matrix, varsvars vector, or a vars*(vars-1)/2 vector) - @
varnames
: optional names for the variables (string vector of length vars) defaults if r is a matrix with column names - @
empirical
: logical. If true, mu, sd and r specify the empirical not population mean, sd and covariance - @
as.matrix
: logical. If true, returns a matrix
Examples
julia> tovector(1) == [1]
julia> tovector(1) != 1
julia> tovector(1:3) == [1,2,3]
Faux.select_by_type
— Functionselect_by_type(df)
Select columns from a DataFrame of a specific type
Arguments
df
: The DataFrametype
: The type of column to select
Examples
julia> df = DataFrame(s = ["A", "B"],
i = [1,2],
n = [1.1, 2.2],
b = [true, false]);
julia> select_by_type(df)
julia> select_by_type(df, Int64)
julia> select_by_type(df, String)
julia> select_by_type(df, Bool)
Faux.sim_design
— Methodsim_design(within = [],
between = [],
n = 100, mu = 0, sd = 1, r = 0,
empirical::Bool = false,
long::Bool = false,
dv::String = "y",
id::String = "id",
vardesc::Dict = Dict(),
sep::String = "_",
rep::Int64 = 1)
Simulate data from design
Generates a data table with a specified within and between design.
Arguments
within
: an array of Pairs for the within-subject factorsbetween
: an array of Pairs for the between-subject factorsn
: the number of samples required per between-subject cellmu
: the means of the variablessd
: the standard deviations of the variablesr
: the correlations among the variables (can be a single number, full correlation matrix as a matrix or vector, or a vector of the upper right triangle of the correlation matrixempirical
: if true, mu, sd and r specify the empirical not population mean, sd and covariancelong
: Whether the returned tbl is in wide or long format (defaults to value offaux_options("long")
)dv
: the name of the dv column for long plots (defaults to y)id
: the name of the id column (defaults to id)vardesc
: a Dict of variable descriptions having the names of the within- and between-subject factorsrep
: the number of data frames to simulate (default 1); if greater than 1, the returned data frame contains a rep columnsep
: separator for factor levels
Examples
julia> using Faux, DataStructures
julia> b = ["condition" => ["ctl", "exp"]]
julia> w = ["version" => ["A", "B"]]
julia> df = sim_design(within = w, between = b, n = 10)
Faux.tovector
— Methodtovector(x)
Convert a UnitRange or single value to a vector
Arguments
x
: The value to convert
Examples
julia> tovector(1)
[1]
julia> tovector(1:3)
[1,2,3]