我首次尝试构建共同作者PubMed出版物的二分图(226条记录)。以下是输入文件的示例(只有一行CSV):
> InputFile = 'JMMolina_PubMed.csv'
# Read the CSV input file into the initial JMMpubs data frame
> setwd('~/Dropbox/R')
> JMMpubs <- read.csv(file=InputFile , header =
> FALSE , sep = ";" , strip.white = TRUE)
> names(JMMpubs) <- c("ID","AuthList", "Year", "Month", "Title")
# build a new data frame IdAuth with one Id line for each coauthor
# therefor the first article which has 13 co-authors will generate 13 lines with the same Id
> Authors <- strsplit(as.character(JMMpubs$AuthList), split = ", ")
> IdAuth <- data.frame(Id = rep(JMMpubs$ID, sapply(Authors,length)), Author = unlist(Authors))
# Now I would like to export this data to Gephi
# The nodes of the graph should be the UNIQUE names in Authors
> UniqueAuthors <- unique(unlist(Authors))
IdAuth
图表的边缘应该是JMMpubs$Year
的每一行。我想将出版物onkeydown
的年份与每个边缘相关联(用较淡的色调绘制红色和较旧的边缘)。
答案 0 :(得分:0)
我有类似的问题。我的解决方案如下。
为了实现这个目的,你可以告诉我需要重新调整你的数据。 如果我理解正确,您需要与ID相关联的作者。 原始答案位于用户1317221_G
的帖子https://stackoverflow.com/a/16177624/8080865上我会将DF设置为:
df3<-data.frame(Author = c("fawf", "ewew", "wewe", "wrewe", "zare")
ID= "11", "11", "11"... etc)´
###TNET solution WoRKS
#create an identifier df for each author
dfnames <- data.frame(i = as.numeric(df3$Id),
value = df$author)
library(tnet)
tdf <- as.tnet( cbind(df3[,1],df3[,2]), type="binary two-mode tnet")
relations <- projecting_tm(tdf, method = "sum")
# match original names
relations[["i"]] <- dfnames[match(relations[['i']], dfnames[['']] ) , 'value']
relations[["j"]] <- dfnames[match(relations[['j']], dfnames[['i']] ) , 'value']
# clean up names
names(relations) <- c("source" , "target", "weight")
我希望这可以帮助你找到答案吗?