generate_adj_matrix: generate_adj_matrix

Description Usage Arguments Details Author(s) Examples

View source: R/generate_adj_matrix.R

Description

Generates a blank adjacency matrix from a specified string

Usage

1
generate_adj_matrix(string_data, data_separator = ",", remove_spaces = F)

Arguments

string_data

The 'string_data' argument is the string from which the unique values and matrix will be generated.

data_separator

The 'data_separator' argument is the chracter separating specified substrings in the given string. Default is ','.

remove_spaces

The 'remove_spaces' argument will remove spaces from the header values (thus disrupting the search unless all spaces are removed in the given string in next steps). This is useful for separating strings with an irregular number of spaces between the same substrings.

Details

Generates an adjacency matrix from a given string. Detects unique values and generates a blank matrix with colnames and rownames of each unique value in supplied string. Data must be provided as a character string.

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 Jan. 29, 2018, 12:45 a.m.