Learn R Programming

glmmrBase (version 1.0.0)

match_rows: Generate matrix mapping between data frames

Description

For a data frames `x` and `target`, the function will return a matrix mapping the rows of `x` to those of `target`.

Usage

match_rows(x, target, by)

Value

A matrix with nrow(x) rows and nrow(target) columns

Arguments

x

data.frame

target

data.frame to map to

by

vector of strings naming columns in `x` and `target`

Details

`x` is a data frame with n rows and `target` a data frame with m rows. This function will return a n times m matrix that maps the rows of `x` to those of `target` based on the values in the columns specified by the argument `by`

Examples

Run this code
df <- nelder(~(cl(10)*t(5)) > ind(10))
df_unique <- df[!duplicated(df[,c('cl','t')]),]
match_rows(df,df_unique,c('cl','t'))

Run the code above in your browser using DataLab