df2matrix: Translates a data.frame, formatted for use in multiple...

View source: R/df2matrix.R

df2matrixR Documentation

Translates a data.frame, formatted for use in multiple membership modelling in MLwiN, to a matrix.

Description

Translates a data.frame, in a form usable by MLwiN for multiple membership models, into a matrix. The data.frame needs to contain (a) columns with membership IDs (e.g. first row of which might be 2, 3, 5, 6, 0, 0) and (b) columns containing weights (e.g. first row of which might be 0.25, 0.25, 0.25, 0.25, 0, 0; in this example the first row of resulting matrix would be 0, 1, 1, 0, 1, 1).

Usage

df2matrix(data, idcols, weightcols)

Arguments

data

A data.frame object.

idcols

String vector of the identifier column names.

weightcols

String vector of the weight column names.

Value

An adjacency matrix as returned by sparseMatrix.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol, U.K.

See Also

matrix2df


R2MLwiN documentation built on May 29, 2024, 2:10 a.m.