Skip to content

Commit fb56657

Browse files
committed
Removed unnecessary returns
1 parent c824455 commit fb56657

File tree

8 files changed

+23
-25
lines changed

8 files changed

+23
-25
lines changed

R/Data_import.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ make_graph_from_df <- function(data, delimiter = ";", column_name = "Author", di
3030

3131
graph <- igraph::graph_from_data_frame(edges, directed = directed)
3232
print(paste0("Constructed network with ", graph |> igraph::vcount(), " authors"))
33-
return(graph)
33+
graph
3434
}
3535

3636
#' @export
@@ -93,5 +93,5 @@ read_metadata <- function(metadata) {
9393
metadata$Data_source_url <- NULL
9494
names(metadata) <- gsub("_", " ", names(metadata))
9595

96-
return(metadata)
96+
metadata
9797
}

R/Date_manager.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ get_years_from_to <- function(data, config) {
1616
years_from <- year_from
1717
years_to <- year_to
1818
}
19-
return(list(years_from = years_from, years_to = years_to))
19+
list(years_from = years_from, years_to = years_to)
2020
}
2121

2222
#' @export

R/Descriptive_stats.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ get_author_stats <- function(data, author_column_name = "Author", delimiter = ";
1111
all_authors <- unique(unlist(strsplit(paste(author_column, collapse = delimiter), delimiter)))
1212
unique_author_count <- length(all_authors)
1313

14-
return(list(
14+
list(
1515
sum = unique_author_count,
1616
average = avg_authors,
1717
median = median_authors,
1818
min = min_authors,
1919
max = max_authors
20-
))
20+
)
2121
}
2222

2323
#' @export

R/Filtering.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ filter_papers_by_authors <- function(data, column_name = "Author", delimiter = "
3636
dplyr::select(-item_list, -Num_items)
3737
print(paste0(nrow(filtered_data), " papers were included in the network analysis."))
3838

39-
return(list(filtered_data, too_many, too_few))
39+
list(filtered_data, too_many, too_few)
4040
}
4141

4242
#' @export
@@ -70,5 +70,5 @@ filter_infrequent_authors <- function(data, column_name = "Author", delimiter =
7070
print(paste0("Removed ", removed_authors, " authors that appeared less than ", min_occurrences, " times."))
7171
}
7272

73-
return(list(filtered_data, removed_authors))
73+
list(filtered_data, removed_authors)
7474
}

R/Interactions.plots.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ plot_graph.Interactions <- function(interactions, centrality = "degree", output_
3737
}
3838

3939
dev.off()
40-
return(output_file)
40+
output_file
4141
}
4242

4343
plot_graph <- function(interactions, centrality, output_file) {
@@ -92,7 +92,7 @@ plot_cutpoints.Interactions <- function(interactions, centrality = "degree", out
9292

9393
dev.off()
9494
}
95-
return(output_file)
95+
output_file
9696
}
9797

9898
plot_cutpoints <- function(interactions, centrality, output_file) {
@@ -136,7 +136,7 @@ plot_top_authors.Interactions <- function(interactions, n = 10, output_file = "o
136136
)
137137

138138
dev.off()
139-
return(output_file)
139+
output_file
140140
}
141141

142142
plot_top_authors <- function(interactions, n, output_file) {
@@ -182,4 +182,4 @@ get_palette <- function(alpha = 1) {
182182
"#FF1493", "#0000FF", "#000000", "#4682B4", "#00CED1",
183183
"#00FF00", "#808000", "#FFFF00", "#FF8C00", "#A52A2A"
184184
), alpha.f = alpha)
185-
}
185+
}

R/Interactions_class.r

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Interactions <- function(data,
6363

6464
class(interactions) <- "Interactions"
6565

66-
return(interactions)
66+
interactions
6767
}
6868

6969
#' @export
@@ -79,7 +79,7 @@ generate_network_metrics.Interactions <- function(interactions) {
7979
interactions$top_authors_degree <- get_most_central_authors(interactions, centrality = "degree", n = 15)
8080
interactions$top_authors_betweenness <- get_most_central_authors(interactions, centrality = "betweenness", n = 15)
8181
interactions$top_authors_harmonic <- get_most_central_authors(interactions, centrality = "harmonic", n = 15)
82-
return(interactions)
82+
interactions
8383
}
8484

8585
generate_network_metrics <- function(interactions) {
@@ -94,7 +94,7 @@ generate_figures.Interactions <- function(interactions, paths, date_range) {
9494
fig4 <- plot_graph(interactions, centrality = "betweenness", output_file = paste0(paths$figures, "/graph_betweenness_", date_range, ".png"))
9595
fig5 <- plot_graph(interactions, centrality = "harmonic", output_file = paste0(paths$figures, "/graph_harmonic_", date_range, ".png"))
9696
fig6 <- plot_graph(interactions, centrality = "none", output_file = paste0(paths$figures, "/graph_no_centrality_", date_range, ".png"))
97-
return(list(fig1 = fig1, fig2 = fig2, fig3 = fig3, fig4 = fig4, fig5 = fig5, fig6 = fig6))
97+
list(fig1 = fig1, fig2 = fig2, fig3 = fig3, fig4 = fig4, fig5 = fig5, fig6 = fig6)
9898
}
9999

100100
generate_figures <- function(interactions, paths, date_range) {
@@ -106,7 +106,7 @@ get_cohesion.Interactions <- function(interactions) {
106106
dyadcount <- network::network.dyadcount(interactions$network)
107107
edgecount <- network::network.edgecount(interactions$network)
108108
size <- network::network.size(interactions$network)
109-
return(list(dyadcount = dyadcount, edgecount = edgecount, size = size))
109+
list(dyadcount = dyadcount, edgecount = edgecount, size = size)
110110
}
111111

112112
get_cohesion <- function(interactions) {
@@ -136,7 +136,7 @@ get_centrality.Interactions <- function(interactions) {
136136
degree <- igraph::degree(interactions$graph)
137137
harmonic <- igraph::harmonic_centrality(interactions$graph)
138138
betweenness <- igraph::betweenness(interactions$graph)
139-
return(list(degree = degree, harmonic = harmonic, betweenness = betweenness))
139+
list(degree = degree, harmonic = harmonic, betweenness = betweenness)
140140
}
141141

142142
get_centrality <- function(interactions) {
@@ -148,7 +148,7 @@ get_diameter.Interactions <- function(interactions) {
148148
diameter <- igraph::diameter(interactions$graph, directed = interactions$directed, weights = NULL)
149149
shortest_paths <- igraph::distances(interactions$graph)
150150
average_shortest_path <- mean(shortest_paths[shortest_paths != Inf])
151-
return(list(diameter = diameter, average_shortest_path = average_shortest_path))
151+
list(diameter = diameter, average_shortest_path = average_shortest_path)
152152
}
153153

154154
get_diameter <- function(interactions) {
@@ -160,9 +160,7 @@ get_reachability.Interactions <- function(interactions) {
160160
reachability_matrix <- sna::reachability(interactions$network)
161161
num_nodes <- nrow(reachability_matrix)
162162
total_pairs <- num_nodes * (num_nodes - 1)
163-
num_unreachable_pairs <- sum(reachability_matrix == 0) - num_nodes
164-
unreachable_fraction <- num_unreachable_pairs / total_pairs
165-
return(unreachable_fraction)
163+
(sum(reachability_matrix == 0) - num_nodes) / total_pairs
166164
}
167165

168166
get_reachability <- function(interactions) {

R/Paths_resolver.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Paths <- function(config) {
1515

1616
class(paths) <- "Paths"
1717

18-
return(paths)
18+
paths
1919
}
2020

2121
create_output_paths <- function(config) {
@@ -35,7 +35,7 @@ create_output_paths <- function(config) {
3535
if (!dir.exists(data_path)) {
3636
dir.create(data_path, recursive = TRUE)
3737
}
38-
return(config)
38+
config
3939
}
4040

4141
get_input_path <- function(config) {

R/Text_utils.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ format_names <- function(name_list) {
2929
} else {
3030
formatted_name <- name
3131
}
32-
return(formatted_name)
32+
formatted_name
3333
})
34-
return(name_list)
34+
name_list
3535
}
3636

3737
#' @export
@@ -67,5 +67,5 @@ escape_latex <- function(text) {
6767
text <- gsub("\\}", "\\\\}", text)
6868
text <- gsub("\\^", "\\\\textasciicircum{}", text)
6969
text <- gsub("~", "\\\\textasciitilde{}", text)
70-
return(text)
70+
text
7171
}

0 commit comments

Comments
 (0)