Description Usage Arguments Details Value See Also Examples
View source: R/prepare_categorical_force.R
This function prepares a binary network for SETSe projection.
1 | prepare_categorical_force(g, node_names, force_var, sum_to_one = TRUE)
|
g |
an igraph object |
node_names |
a character string. A vertex attribute which contains the node names. |
force_var |
A vector of force attributes. This describes all the categorical force attributes of the network. All named attributes must be either character or factor attributes. |
sum_to_one |
Logical. whether the total positive force sums to 1, if FALSE the total is the sum of the positive cases |
The network takes in an igraph object and produces an undirected igraph object that can be used with the embedding functions.
The purpose of the function is to easily be able to project categorical features using SETSe. The function creates new variables where each variable represents one level of the categorical variables. For embedding only n-1 of the levels are needed.
The function creates several variables of the format "force_". Vertex attributes representing the force produced by each node for each categorical value, there will be n of these variables representing each level of the categorical values. The variable names will be the the name of the variable and the name of the level seperated by and underscore. For example, with a variable group and levels A and B, the created force variables will be "group_A" and "group_B" The sum of these variables will be 0.
A network with the correct node attributes for the embeddings process.
setse, setse_auto, setse_bicomp, setse_auto_hd
Other prepare_setse:
prepare_continuous_force()
,
prepare_edges()
1 2 3 4 5 6 7 8 9 | set.seed(234) #set the random see for generating the network
g <- generate_peels_network(type = "E")
embeddings <- g %>%
prepare_edges(k = 500, distance = 1) %>%
#prepare the network for a binary embedding
prepare_categorical_force(., node_names = "name",
force_var = "class") %>%
#embed the network using auto_setse
setse_auto(., force = "class_A")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.