string_2_matrix {String2AdjMatrix} | R Documentation |
string_2_matrix
Description
Creates an adjacency matrix
Usage
string_2_matrix(new_matrix, supplied_string, self = 0)
Arguments
new_matrix |
The 'new_matrix' element of the function should be either the matrix generated by 'generate_adj_matrix()' or an empty data matrix of equal number of rows and columns. These should have unique values specified as the row names and column names. |
supplied_string |
The ‘supplied_string' element refers to the string in which the search is to be performed. i.e 'list = c(’apples, pears, bananas', 'apples, bananas', 'apples, pears')' |
self |
The 'self' option specifies how to handle data when the specified object is found within a string. Default is 0. i.e. the adjacency matrix does not count it when the substring is found, only when the substring is found in combination with another unique substring. |
Value
An adjacency matrix
Note
Generating large matrices is computationally intensive and may take a while.
Author(s)
Tom Drake
Examples
##Example
library(String2AdjMatrix)
#Start with character string to generate an adjacency matrix from
string_in = c('apples, pears, bananas', 'apples, bananas', 'apples, pears')
#Generate a new blank matrix
blank_matrix = generate_adj_matrix(string_in)
#Now fill the matrix
string_2_matrix(blank_matrix, string_in)