2017-10-29 6 views
-4

共著者のPubMedの出版物(226レコード)の2部グラフを作成する私の最初の試み。以下は、入力ファイル(一つだけCSVライン)のサンプルである:Rデータを.GEXF形式に変換する

11810598;Chêne G, Angelini E, Cotte L, Lang JM, Morlat P, Rancinan C, May T, Journot V, Raffi F, Jarrousse B, Grappin M, Lepeu G, Molina JM;2002;Mar;Role of long-term nucleoside-analogue therapy in lipodystrophy and metabolic disorders in human immunodeficiency virus-infected patients. 

 

> 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の各列でなければなりません。出版物の年を各辺に関連付ける(最新の辺を赤く塗りつぶし、古いものを淡い色で塗りつぶす)。

答えて

0

私は同様の問題があります。私の解決策は次のとおりです。

これが機能するためには、あなたのデータを少し改造する必要があると私には分かります。 私が正しく理解している場合は、IDに接続している作者が必要です。私は、これはあなたがあなたの答えを見つけ出すのに役立ちます願ってい

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") 

: オリジナルの答えは、と私はDFを設定しますuser1317221_G

によって、このポストhttps://stackoverflow.com/a/16177624/8080865にありますか?

関連する問題