cols2Env {AnnBuilder}R Documentation

Creates a environment object using data from two columns of a matrix


Given a matrix with two columns, this function creates an environment object with values in one of the specified columns as keys and those in the other column as values.


cols2Env(cols, colNames, keyColName = colNames[1], sep)
matchAll(cols, keyColName)
matchOneRow(cols, keyColName, sep = ";")


cols cols a matrix with two columns
colNames colNames a character string for the name of the column whose values will be used for the keys of the environment object to be created
keyColName keyColName a character string for the name of the column whose values will be the corresponding values for keys of the environment object to be created
sep sep a character for the separators used to separate entries that have multiple values


The matrix or matrix convertible object passed to cols2Env must have two coloumns with one intended to be used as the key and the other be the value.

Cells in either or both columns may have multiple values separated by a separator (e.g. "a;b", "1;2;3") making the mapping between keys and the corresponding values not a straitforward operation. cols2Env gets all the unique values from the key column by spliting them and maps values to each of them.

cols2Env calls matchAll that in turn calls matchOneRow to first split entries and then map entries in the two coloumns on one to one bases. Unique keys in the column defined as the key column will be assigned a vector containing all the values corresponding the keys in the environment to return.


This function returns an environment object with key and value pairs


This function is part of the Bioconductor project at Dana-Farber Cancer Institute to provide Bioinformatics functionalities through R


Jianhua Zhang

See Also



dataM <- matrix(c("a;b", "1;2;3", "a;b", "4;5", "c", "6;7", "b;a",
"6;7;8"), ncol = 2, byrow = TRUE)

temp <- cols2Env(dataM, c("key", "value"), keyColName = "key")

mget(ls(temp), temp)

[Package AnnBuilder version 1.4.21 Index]