Closed n-galanos closed 7 months ago
No matter how many different ways I try the codes, I'm still coming up with "numeric (0)" when running standardized degree for each actor.
hi @n-galanos ! Sorry you are running into this issue. The error is on the 4th line of your code. Let me show you.
Run this:
# load the libraries we need
library( sna )
library( network )
# define the path location for the file
loc <- "https://github.com/jacobtnyoung/sna-textbook/raw/main/data/data-london-gang-net.rds"
LondonGangNet <- readRDS( url(loc ) )
# define the degrees
deg.g <- colSums( as.matrix( LondonGangNet ) )
# define the number of nodes
g <- dim( LondonGangNet )[1]
#print out g
g
You should get an indication that the object g
is NULL
. This is because the object LondonGangNet
is one of class network
, not matrix
. So it does not have dimensionality that the dim()
function is looking to report.
The way to overcome this is to just continue to coerce the object to a matrix, like you did in the first line of your code. So, try this:
g <- dim( as.matrix( LondonGangNet ) )[1]
Make sense? Let me know if you are still running into issues!
Yes that worked!! Thank you so much! Is this what I will do for Part 2 Question 3 as well using CocaineDealingNet?
Hi @n-galanos ! Yes, you can do it that way.
Or, you can use the degree()
function. That is easier, I think, but it is your call.
I need some help with Part 1, Question 3: Calculate the standardized degree for each actor.
When reviewing the tutorial (I attached a screenshot of what I'm referring to), I am unclear about how to connect LondonGangNet to how the tutorial shows how to calculate the standardized degree.
I have tried many different ways such as;
I believe I messed up along the way with my coding since I came up with: numeric(0).
Im also having an issue with standardized degree for Part 2 as well, getting the error "numeric(0)".
When I try to continue by coding the Mean, I receive the same "numeric(0)" error.