Skip to contents

Transforms a vector with a normal distribution to a binomial distribution with two values.

Usage

norm2ordinal(x, k)

Arguments

x

Input vector

k

Number of discrete values (e.g., 2=binary, 5=likert scale)

Value

A ordinal or binary variable

Examples

norm2ordinal(x = rnorm(n = 100,mean = 0,sd = 1),k=2)
#>              [,1]
#>   [1,]  1.0565903
#>   [2,]  1.0565903
#>   [3,]  1.0565903
#>   [4,] -0.9369763
#>   [5,] -0.9369763
#>   [6,]  1.0565903
#>   [7,]  1.0565903
#>   [8,]  1.0565903
#>   [9,] -0.9369763
#>  [10,] -0.9369763
#>  [11,] -0.9369763
#>  [12,] -0.9369763
#>  [13,]  1.0565903
#>  [14,]  1.0565903
#>  [15,] -0.9369763
#>  [16,] -0.9369763
#>  [17,] -0.9369763
#>  [18,]  1.0565903
#>  [19,] -0.9369763
#>  [20,]  1.0565903
#>  [21,] -0.9369763
#>  [22,]  1.0565903
#>  [23,]  1.0565903
#>  [24,]  1.0565903
#>  [25,]  1.0565903
#>  [26,]  1.0565903
#>  [27,] -0.9369763
#>  [28,] -0.9369763
#>  [29,]  1.0565903
#>  [30,] -0.9369763
#>  [31,]  1.0565903
#>  [32,] -0.9369763
#>  [33,]  1.0565903
#>  [34,] -0.9369763
#>  [35,]  1.0565903
#>  [36,] -0.9369763
#>  [37,]  1.0565903
#>  [38,]  1.0565903
#>  [39,] -0.9369763
#>  [40,]  1.0565903
#>  [41,] -0.9369763
#>  [42,] -0.9369763
#>  [43,] -0.9369763
#>  [44,]  1.0565903
#>  [45,] -0.9369763
#>  [46,] -0.9369763
#>  [47,]  1.0565903
#>  [48,] -0.9369763
#>  [49,] -0.9369763
#>  [50,]  1.0565903
#>  [51,] -0.9369763
#>  [52,]  1.0565903
#>  [53,]  1.0565903
#>  [54,] -0.9369763
#>  [55,]  1.0565903
#>  [56,]  1.0565903
#>  [57,] -0.9369763
#>  [58,]  1.0565903
#>  [59,]  1.0565903
#>  [60,]  1.0565903
#>  [61,]  1.0565903
#>  [62,]  1.0565903
#>  [63,]  1.0565903
#>  [64,]  1.0565903
#>  [65,] -0.9369763
#>  [66,] -0.9369763
#>  [67,] -0.9369763
#>  [68,] -0.9369763
#>  [69,]  1.0565903
#>  [70,]  1.0565903
#>  [71,]  1.0565903
#>  [72,] -0.9369763
#>  [73,] -0.9369763
#>  [74,]  1.0565903
#>  [75,] -0.9369763
#>  [76,] -0.9369763
#>  [77,] -0.9369763
#>  [78,] -0.9369763
#>  [79,] -0.9369763
#>  [80,] -0.9369763
#>  [81,] -0.9369763
#>  [82,]  1.0565903
#>  [83,]  1.0565903
#>  [84,]  1.0565903
#>  [85,] -0.9369763
#>  [86,] -0.9369763
#>  [87,] -0.9369763
#>  [88,] -0.9369763
#>  [89,] -0.9369763
#>  [90,] -0.9369763
#>  [91,]  1.0565903
#>  [92,]  1.0565903
#>  [93,]  1.0565903
#>  [94,] -0.9369763
#>  [95,] -0.9369763
#>  [96,]  1.0565903
#>  [97,] -0.9369763
#>  [98,] -0.9369763
#>  [99,] -0.9369763
#> [100,] -0.9369763
#> attr(,"scaled:center")
#> [1] 0.47
#> attr(,"scaled:scale")
#> [1] 0.5016136