Learn R Programming

StratSel (version 1.4)

makeDyadic: A Function To Create Dyadic Data Sets

Description

This function allows the user to create dyadic data sets which can be directed or undirected.

Usage

makeDyadic(x, directed = FALSE, show.progress = 5)

Value

Returns a data frame with the dyadic data set.

Arguments

x

The data matrix whereas the first variable is the country code and the second column has to be the time variable.

directed

Logical. If directed=TRUE the dyadic data set will be directed and have variables with amended names (creating sen_varname for sender and rec_varname for receiver).

show.progress

Logical. The process may take some time depending on the size of the supplied data matrix. This option allows users to receive feedback of how far along the process is at periodical steps. Default is set to 5.

Author

Lucas Leemann lleemann@gmail.com

Details

This function was first written for Simon Collrad-Wexler and then later amended for Fabio Wasserfallen.

Examples

Run this code
dataOrig <- matrix(c( rep(c(1:4),3), rep(1,4), rep(2,4), rep(3,4),
 rnorm(4,1.5,0.1), rnorm(4,2.5,0.1), rnorm(4,3.5,0.1), rnorm(4,4.5,0.1),
 rnorm(4,5.5,0.1), rnorm(4,6.5,0.1)),12,4)
colnames(dataOrig) <- c("countryCODE", "Year", "Variable 1", "Variable 2")
dataNew <- makeDyadic(dataOrig, directed=TRUE)

Run the code above in your browser using DataLab