-3

How can I solve this? Last code isn't coming out during a day Please help And I wrote more code at comment.

code

library(tidygraph)
library(ggproto)
library(tidyverse)
library(igraph)
library(ggraph)
library(ggraphlayouts)
library(colorspace)
library(Rcpp)

resid_link<-read.csv('https://raw.githubusercontent.com/regenesis90/datasets/master/sample01_resid_link.csv')
resid_node_n<-read.csv('https://raw.githubusercontent.com/regenesis90/datasets/master/sample01_resid_node_n.csv')

resid_link[,1]%in% resid_node_n[,1]
resid_link[,2]%in% resid_node_n[,1]

read_network<-graph_from_data_frame(d=resid_link, vertices=resid_node_n)
  • 1
    Please do not post an image of code/data/errors: it cannot be copied or searched (SEO), it breaks screen-readers, and it may not fit well on some mobile devices. Ref: https://meta.stackoverflow.com/a/285557 (and https://xkcd.com/2116/). Please just include the code, console output, or data (e.g., `data.frame(...)` or the output from `dput(head(x))`) directly. – r2evans Jul 19 '21 at 00:14
  • ggraph(resid_network,layout+'stress')+ geom_edge_link(aes(alpha=weight),colour='#cfcbc4', edge_width=1)+geom_node_point(aes(size=n, fill=resid_sector, color=resid_sector), shape=21, stroke=1.5)+geom_node_text(aes(label=name),fontface='bold', color='white',size=3)+ scale_size_continuous(range=c(2,7))+ theme_void()+theme(legend.position='right')+scale_fill_discrete_qualitative(palette='set3',nmax=10)+scale_color_discrete_qualitative(palette='set2', nmax=10)+ guides(col=guide_legend(ncol=1),fill=guide_legend(ncol=1)) – 로젠시아 Jul 19 '21 at 01:55
  • That's what I can't make to come out. Please help – 로젠시아 Jul 19 '21 at 01:55

1 Answers1

1

From what I can tell, you used the wrong variable name (i.e., resid_network), which should have been read_network. You also need to use layout = 'stress' rather than layout +.

ggraph(read_network, layout =  'stress') +
  geom_edge_link(aes(alpha = weight), colour =
                   '#cfcbc4', edge_width = 1) + geom_node_point(
                     aes(size = n, fill = resid_sector, color = resid_sector),
                     shape = 21,
                     stroke = 1.5
                   ) +
  geom_node_text(aes(label = name),
                 fontface = 'bold',
                 color = 'white',
                 size = 3) + scale_size_continuous(range = c(2, 7)) +
  theme_void() + theme(legend.position =
                         'right') +
  scale_fill_discrete_qualitative(palette = 'set3', nmax = 10) +
  scale_color_discrete_qualitative(palette = 'set2', nmax = 10) +
  guides(col =
           guide_legend(ncol = 1), fill = guide_legend(ncol = 1))

enter image description here

AndrewGB
  • 16,126
  • 5
  • 18
  • 49