string_2_matrix: string_2_matrix

Description Usage Arguments Value Note Author(s) Examples

Description

Creates an adjacency matrix

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
##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)

tomdrake/String2AdjMatrix documentation built on May 23, 2019, 6:06 a.m.