Question: The example code: as _ adjacency _ matrix ( g _ the _ princess _ bride, attr = weight, type = both ) | >
The example code:
asadjacencymatrixgtheprincessbride, attr "weight", type "both"
# convert "sparse matrix" format to matrix, and then to tibble
asmatrix astibblerownames "from"
# pivot from wide to long format
pivotlongerfrom, namesto to valuesto "weight"
# plot the heatmap using ggplot
ggplot geomtileaesx to y from, fill weight color "gray
scalefillgradientlow "white", high "darkblue"
themeaxistext.x elementtextangle hjust vjust
write R code using ggplot or the ggraph library for a shakespeare:
heatmapdata asadjacencymatrixnetwork attr "weight", type "both"
asmatrix
astibblerownames "from"
pivotlongerfrom, namesto to valuesto "weight"
ggplotheatmapdata, aesx to y from, fill weight
geomtilecolor "gray
scalefillgradientlow "white", high "darkblue"
thememinimal
themeaxistext.x elementtextangle hjust vjust
labstitle "Shakespeare Network Heatmap", x To y "From"
However, Error in get.adjacency.sparsegraph type type, attr attr, edges edges, :
no such edge attribute
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
