Skip to content

Julia package to create a matrix of 0 and 1 from groups in a vector

License

Notifications You must be signed in to change notification settings

fabrizioleone/Dummyvar.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dummyvar

Build Status

This Julia package allows to create a matrix of zeros and ones from a vector of groups. It reproduces the Matlab's function dummyvar.

The input type must be a Vector. The output matrix has a number of columns equal to the number of unique groups contained in the vector, and the ones indicate those groups.

To use the package, type in the Julia REPL

Pkg.add("Dummyvar")
using Dummyvar

The function dummycreate creates the matrix of zeros and ones. Here are some examples

dummycreate([1.0, 2.0])

2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0

dummycreate(['a', 'b'])

2×2 Matrix{Float64}:
 1.0  0.0
 0.0  1.0
 
dummycreate([1, 'a', 'b'])

3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0
 
dummycreate([1, 'a', 'b', 1])

4×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0
 1.0  0.0  0.0

About

Julia package to create a matrix of 0 and 1 from groups in a vector

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages