library("rtweet")
library("igraph")
user = getUser("elonmusk")
friends = user$getFriends(retryOnRateLimit=10)
follower.count = c()
for (a in c(1:length(friends))){
follower.count[a] =
friends[[a]]$getFollowersCount()
}
o=order(follower.count, decreasing = TRUE)[1:10]
topPopFriends = friends[o]
#---------Show top friends------
topPopFriends
#----Get IDs of the top 10 friends-------
topFriendIDs = c()
for (i in 1:10){
topFriendIDs = c(topFriendIDs,topPopFriends[[i]][[".->id"]])
}
friendGraph = c()
for (i in 1:10) {
user = getUser(topPopFriends[[i]])
friendIDs = user$getFriendIDs(7000,retryOnRateLimit=10)
if (!is.null(friendIDs)) {
for (j in 1:length(friendIDs)) {
for (k in 1:10) {
if (friendIDs[j] == topFriendIDs[k])
friendGraph = c(friendGraph,topPopFriends[[i]][[".->id"]], friendIDs[j])
}
}
}
}
#----------Convert IDs to names--------
for (i in 1:length(friendGraph)){
user = getUser(friendGraph[[i]])
friendGraph[i] = user$name
}
#-------Make top 10 edgelist-------
fGraph = rep("elonmusk", 10)
fd =c90
for (i in 1:10) {
fd = c(fd, topFriends[[i]][[".->name"]])
}
fGraph = cbind(fGraph, fd)
#-----combine the friendgraph with the elonmusk's-----
f = matrix(friendGraph, ncol=2, byrow=TRUE)
fGraph = rbind(fGraph,f)
#----Plot the graph----
grapfingraphfin = graph.edgelist(fGraph, directed = T)
plot(graphfin, layout=layout_nicely, vertex.size = 10, edge.color="orange", vertex.color="gray50", edge.arrow.size=.15, margin =.001, family="Helveltica")
#-----Sort and find ----
sort(betweenness(graphfin), decreasing=TRUE)
Hey guys so this is my code but when i run it the warning messages come out
Warning messages:
1: Unknown or uninitialised column: getFriends
.
2: Unknown or uninitialised column: getFriendIDs
.
Anyone can help me ?
Thank you