Closed jjgillis0 closed 7 months ago
Hi @jjgillis0 !
It looks like you are trying to rebuild the matrix "by hand". There are two problems here. First, at the beginning of each line you are calling an object. For example, in the first line R is looking for the object Bill
. But this object does not exist. Remember that characters require "", as you do in the rownames
command.
But, I am not sure why you are doing this in the first place. All you need to do is download the file using the code below (and in the template):
library( sna )
library( network )
# define the path location for the file
loc2 <- "https://github.com/jacobtnyoung/sna-textbook/raw/main/data/data-cocaine-dealing-net.rds"
CocaineDealingNet <- readRDS( url( loc2 ) )
# plot it
gplot( CocaineDealingNet )
# create an object of matrix
CocaineDealingMatrix <- as.matrix( CocaineDealingNet )
If this code does not work, then you need to recheck your internet connection.
Let me know if that solves the problem!
Oh thank you! I was thinking it was similar to the undirected network.
Hello Professor Young~ Below is my code, and I assume it's coming from my URL , but redoing that part still gave me the error: object 'Bill' not found, and when I do the colnames, I get the error: object 'd.mat' not found.
Hopefully, it is an easy fix, but I can't find my error.
Thank you, Jenny
loc2 <- "https://raw.githubusercontent.com/jacobtnyoung/sna-textbook/main/data/data-cocaine-dealing-net.rds" CocaineDealingNet <- readRDS( url(loc2 ) )
look at the network
CocaineDealingNet