Faux

Documentation for Faux.

Faux.rep_lenMethod
rep_len(x, len)

Repeat a value or vector to create a vector of specified length

Arguments

  • x: The value or vector to repeat
  • len: 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]
source
Faux.rnorm_multiMethod
rnorm_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]
source
Faux.select_by_typeFunction
select_by_type(df)

Select columns from a DataFrame of a specific type

Arguments

  • df: The DataFrame
  • type: 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)
source
Faux.sim_designMethod
sim_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 factors
  • between: an array of Pairs for the between-subject factors
  • n: the number of samples required per between-subject cell
  • mu: the means of the variables
  • sd: the standard deviations of the variables
  • r: 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 matrix
  • empirical: if true, mu, sd and r specify the empirical not population mean, sd and covariance
  • long: Whether the returned tbl is in wide or long format (defaults to value of faux_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 factors
  • rep: the number of data frames to simulate (default 1); if greater than 1, the returned data frame contains a rep column
  • sep: 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)
source
Faux.tovectorMethod
tovector(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]
source