Spaces:
Sleeping
Sleeping
Delete OpenAlexEdgesDisp.R
Browse files- OpenAlexEdgesDisp.R +0 -91
OpenAlexEdgesDisp.R
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
authorPubEdgesDisp <- function(keywords,pub_start_date,pub_end_date){
|
2 |
-
|
3 |
-
keywords <- keywords
|
4 |
-
pub_start_date <- pub_start_date
|
5 |
-
pub_end_date <- pub_end_date
|
6 |
-
|
7 |
-
# create search engine function
|
8 |
-
search_engine <- function(keywords,pub_start_date,pub_end_date){
|
9 |
-
suppressPackageStartupMessages(library(openalexR))
|
10 |
-
suppressPackageStartupMessages(library(tidyverse))
|
11 |
-
|
12 |
-
options(openalexR.mailto = "[email protected]")
|
13 |
-
|
14 |
-
# search engine
|
15 |
-
works_search <- oa_fetch(
|
16 |
-
entity = "works",
|
17 |
-
title.search = c(keywords),
|
18 |
-
cited_by_count = ">50",
|
19 |
-
from_publication_date = pub_start_date,
|
20 |
-
to_publication_date = pub_end_date,
|
21 |
-
options = list(sort = "cited_by_count:desc"),
|
22 |
-
verbose = FALSE
|
23 |
-
)
|
24 |
-
|
25 |
-
return(works_search)
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
search_data <- search_engine(keywords,pub_start_date,pub_end_date)
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
# grab authors and group them according to collaboration
|
34 |
-
authors_collaboration_groups <- list()
|
35 |
-
for (i in 1:nrow(search_data)){
|
36 |
-
authors_collaboration_groups[[i]] <- search_data$author[[i]][2]
|
37 |
-
}
|
38 |
-
|
39 |
-
# grab all authors
|
40 |
-
all_authors <- c()
|
41 |
-
for (i in 1:length(authors_collaboration_groups)) {
|
42 |
-
all_authors <- c(all_authors,authors_collaboration_groups[[i]][[1]])
|
43 |
-
}
|
44 |
-
|
45 |
-
# get length of each authors collaboration
|
46 |
-
authors_length <- c()
|
47 |
-
for(authors in 1:length(authors_collaboration_groups)){
|
48 |
-
authors_length <- c(authors_length,authors_collaboration_groups[[authors]] |> nrow())
|
49 |
-
}
|
50 |
-
|
51 |
-
# grab all publications
|
52 |
-
publications <- list()
|
53 |
-
for (i in 1:nrow(search_data)){
|
54 |
-
publications[[i]] <- rep(search_data$display_name[i], each = authors_length[i])
|
55 |
-
}
|
56 |
-
|
57 |
-
# place all publications in a vector
|
58 |
-
all_publications <- c()
|
59 |
-
for(i in 1:length(publications)){
|
60 |
-
all_publications <- c(all_publications,publications[[i]])
|
61 |
-
}
|
62 |
-
|
63 |
-
# create author_to_publication data frame
|
64 |
-
authors_to_publications <- data.frame(
|
65 |
-
Authors = all_authors,
|
66 |
-
Publications = all_publications
|
67 |
-
)
|
68 |
-
|
69 |
-
# create edges data frame
|
70 |
-
author_publication_edges <- data.frame(
|
71 |
-
Source = authors_to_publications$Authors,
|
72 |
-
Target = authors_to_publications$Publications,
|
73 |
-
Type = "directed",
|
74 |
-
Weight = 1.0
|
75 |
-
)
|
76 |
-
|
77 |
-
return(author_publication_edges)
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
disp_data <- authorPubEdgesDisp(keywords = c("data","computing"),
|
82 |
-
pub_start_date = "2022-07-01",
|
83 |
-
pub_end_date = "2023-07-31")
|
84 |
-
|
85 |
-
disp_data |> view()
|
86 |
-
|
87 |
-
mental_health <- authorPubEdgesDisp(keywords = c("depression","anxiety","ptsd"),
|
88 |
-
pub_start_date = "2019-01-01",
|
89 |
-
pub_end_date = "2023-09-30")
|
90 |
-
|
91 |
-
mental_health |> view()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|