-
Notifications
You must be signed in to change notification settings - Fork 0
/
Panel_data_compilation.Rmd
2051 lines (1692 loc) · 109 KB
/
Panel_data_compilation.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Compiling the professor year panel"
author: "Ana Macanovic"
date: "2024-01-29"
output: html_document
---
This script compiles our various data resources into a panel data of professors'
publications, citations, mentions, and coauthorships per year.
Here is the breakdown of the variables used in our main analyses. The code below
also produces some other variables not used in the main analyses.
| **Variable name** | **Variable label** | **Variable description** |
| -------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| _inferred_gender_ | Inferred gender | Gender of professor as inferred in our analysis (see “Gender inference” above) |
| _general_field_ | Field | Professor’s main field as inferred using their overall publication data (see “Publication and citation data” above) |
| _years_since_first_pub_ | Years since first publication | Years elapsed since professor’s first publication (1973 at the earliest) until the year in question |
| _count_pubs_ | Publications | Number of publications of the professor in the year in question |
| _count_pubs_total_ | Total publications | _count_pubs_ accumulated from the first year in which the professor published (1973 at the earliest) up until and including the year in question |
| _cited_by_ | Citations | Number of citations received by all of the professor’s publications (since 1973 at the earliest) in the year in question. Available only between 2012 and 2023, as per Open Alex. |
| _cited_by_total_all_ | Total citations | _cited_by_ accumulated from 2012 up until and including the year in question. This count includes the total number of citations received by the professor on all their publications before 2012 (e.g., the count for 2012 includes the total citations received before 2012 and the citations received in 2012. Available only between 2012 and 2023, as per Open Alex. |
| _news_all_ | Printed news (attention) | Number of news articles retrieved from LexisNexis that mention professor in the year in question. |
| _news_all_total_ | Total printed news (attention) | _news_all_ accumulated up until and including the year in question. |
| _alt_online_all_ | Online news (attention) | Number of online news articles retrieved from Altmetric that relate to a paper by the professor in the year in question. Available only between 2012 and 2023, as per Altmetric. |
| _alt_online_all_total_ | Total online news (attention) | _alt_online_all_ accumulated from 2011 up until and including the year in question. Available only between 2011 and 2023, as per Altmetric. |
| _alt_twitter_ | Twitter/X (attention) | Number of Twitter/X mentions retrieved from Altmetric that relate to the professor in the year in question. Available only between 2012 and 2023, as per Altmetric. |
| _alt_twitter_total_ | Total Twitter/X (attention) | _alt_twitter_ accumulated from 2011 up until and including the year in question. Available only between 2011 and 2023, as per Altmetric. |
| _coa_tot_cited_by_ | Coauthors' citations | Cumulative citations of all coauthors that one has coauthored with in the year in question, counted until the year in question (e.g., for a professor A in 2015, we select all their coauthors in this year and compile their total citations up until and including 2015 and add them up together in the process resembling the one described for _cited_by_ and _cited_by_total_all_). Available only between 2012 and 2023, as per Open Alex. |
| _coa_tot_cited_by_total_ | Coauthors' total citations | _coa_tot_cited_by_ accumulated from 2012 up until and including the year in question. If professor has coauthored with the same coauthor multiple times, we only consider the latest cumulative number of citations of this coauthor. Available only between 2012 and 2023, as per Open Alex. |
| _coa_tot_online_all_ | Coauthors' online attention | Cumulative online news mentions of all coauthors that one has coauthored with in the year in question (compiled in a manner comparable to _coa_tot_cited_by_). Available only between 2011and 2023, as per Altmetric. |
| _coa_tot_online_all_total_ | Coauthors' total online attention | _coa_tot_online_all_ accumulated from 2011 up until and including the year in question. If professor has coauthored with the same coauthor multiple times, we only consider the latest cumulative number of citations of this coauthor. Available only between 2011and 2023, as per Altmetric. |
| _coa_tot_twitter_ | Coauthors’ Twitter/X attention | Cumulative Twitter/X mentions of all coauthors that one has coauthored with in the year in question (compiled in a manner comparable to _coa_tot_cited_by_). Available only between 2011and 2023, as per Altmetric. |
| _coa_tot_twitter_total_ | Coauthors’ total Twitter/X attention | _coa_tot_twitter_ accumulated from 2011 up until and including the year in question. If professor has coauthored with the same coauthor multiple times, we only consider the latest cumulative number of citations of this coauthor. Available only between 2011and 2023, as per Altmetric. |
Load the packages:
```{r message= F, warning = F, eval = T}
# load the helper function file
source("helper_functions.R")
packages_to_load <- c("readr", "dplyr", "tidyr", "PerformanceAnalytics",
"tidyverse", "RPostgres", "lubridate", "psych",
"digest", "DBI", "RODBC", "odbc", "gridExtra",
"panelr", "skimr", "foreach", "vegan", "knitr",
"doParallel")
fpackage_check(packages_to_load)
# For full reproducibility, load the packages with groundhog using the code below instead
# of the fpackage_check function
# library(groundhog)
# groundhog.library(packages_to_load, date = "2023-12-01")
```
```{r include=FALSE}
opts_chunk$set(echo = TRUE)
opts_chunk$set(eval = FALSE)
opts_chunk$set(warning = FALSE)
opts_chunk$set(message = FALSE)
```
Connect to the database:
```{r}
# fill in own credentials
port <- 5432
user <- "postgres"
password <- "dutchmediaprofssql"
database_name <- "postgres"
con <- dbConnect(Postgres(),
dbname= database_name,
port = port,
user = user,
password = password)
con # Checks connection is working
```
# NARCIS data
Load the professor NARCIS profiles to start with
```{r message = F, warning = F}
narcis_prof_info <- dbReadTable(con, "narcis_prof_info")
```
# Publications and citations
Load publication info for all professors and tidy it up:
```{r}
# all professors, their pubs, and the yearly citation breakdown
oa_prof_pubs <- dbReadTable(con, "oa_prof_pubs")
# detailed information about pubications
oa_pubs_unique <- dbReadTable(con, "oa_prof_pubs_unique")
# dataset matching professor IDs to publications
oa_prof_pub_matching <- dbReadTable(con, "oa_prof_pub_match")
# match publication infromation with professors
oa_prof_pubs_unique <- merge(oa_pubs_unique,
oa_prof_pub_matching[c("id", "au_id", "au_display_name", "profile_id")],
all.x = TRUE,
all.y = TRUE,
by = "id")
```
Get single author publications only:
```{r}
# get information listing coauthors (au_id) per paper (id)
coauthor_info <- dbGetQuery(con, "select \"id\", \"au_id\" FROM oa_coauthor_info;")
# leave only publications without any coauthors
oa_prof_pubs_unique_single_au <- filter(oa_prof_pubs_unique,
! id %in% coauthor_info$id)
```
## Yearly publication counts
Get yearly publication counts per professor, filtering out everything but articles,
books, book chapters:
```{r}
prof_year_pubs <- oa_prof_pubs_unique %>%
filter(!is.na(publication_year) & publication_year >= 1973 & publication_year <= 2023 &
type %in% c("article", "book", "book-chapter"))%>%
group_by(profile_id, publication_year)%>%
summarise(count_pubs = n())%>%
arrange(profile_id, publication_year)%>%
mutate(count_pubs_total = cumsum(count_pubs))%>%
arrange(profile_id, publication_year)
# rename for merging
colnames(prof_year_pubs)[which(colnames(prof_year_pubs) == "publication_year")] <- "year"
```
Now, get their yearly citations (2012-2024):
```{r}
prof_year_citations <- oa_prof_pubs %>%
filter(!is.na(publication_year) & !is.na(counts_by_year_year) & publication_year >= 1973 & publication_year <= 2023 &
type %in% c("article", "book", "book-chapter"))%>%
group_by(profile_id, counts_by_year_year)%>%
summarise(cited_by = sum(counts_by_year_cited_by_count))%>%
arrange(profile_id, counts_by_year_year) %>%
mutate(cited_by_total_oa = cumsum(cited_by))%>%
arrange(profile_id, counts_by_year_year)
# rename for merging
colnames(prof_year_citations)[which(colnames(prof_year_citations) == "counts_by_year_year")] <- "year"
```
Now, we want to know how many citations there were before 2012, so we get the totals
and then generate a new column getting the pre-2012 citations + each year's citations:
```{r}
# total citations per prof
prof_total_citations <- oa_prof_pubs_unique %>%
filter(!is.na(publication_year) & publication_year >= 1973 & publication_year <= 2023 &
type %in% c("article", "book", "book-chapter"))%>%
group_by(profile_id)%>%
summarise(cited_by_since_pub_2024 = sum(cited_by_count))
# rename for merging
colnames(prof_total_citations)[which(colnames(prof_total_citations) == "publication_year")] <- "year"
# get the citations preceding 2012 by deducting the 2012 citations from the total
latest_citation <- prof_year_citations %>%
group_by(profile_id)%>%
slice(which.max(year))
# merge these two, replace NAs
prof_total_citations <- merge(prof_total_citations,
latest_citation[c("profile_id", "cited_by_total_oa")],
by = "profile_id",
all.x = TRUE,
all.y = TRUE)
prof_total_citations <- prof_total_citations %>%
replace(is.na(.), 0)
# get the citation count for profs before 2012
prof_total_citations$cited_by_before_2012 <- prof_total_citations$cited_by_since_pub_2024 - prof_total_citations$cited_by_total_oa
# if this number negative (which it can be due to OA problems), replace by 0
prof_total_citations$cited_by_before_2012 <- ifelse(prof_total_citations$cited_by_before_2012 < 0,
0,
prof_total_citations$cited_by_before_2012)
# merge this with citation data
prof_year_citations <- merge(prof_year_citations,
prof_total_citations[c("profile_id", "cited_by_before_2012")],
all.x = TRUE,
by = "profile_id")
# get cumulative citations of pre 2012 + the year in question
prof_year_citations$cited_by_total_all <- prof_year_citations$cited_by_total_oa + prof_year_citations$cited_by_before_2012
# combine publication counts and citation counts, filling gaps with NAs
prof_year_pubs_citations <- merge(prof_year_pubs,
prof_year_citations,
all.x = TRUE,
all.y = TRUE,
by = c("profile_id", "year"))
# fill some NAs for publication counts, but we will not do this for citations
prof_year_pubs_citations$count_pubs <- ifelse(is.na(prof_year_pubs_citations$count_pubs),
0,
prof_year_pubs_citations$count_pubs)
# fill the total gaps down for cumulative publications
prof_year_pubs_citations <- prof_year_pubs_citations %>%
group_by(profile_id)%>%
fill(count_pubs_total)
# fill the citations before 2012
prof_year_pubs_citations <- prof_year_pubs_citations %>%
group_by(profile_id)%>%
fill(cited_by_before_2012, .direction = "up")
# publications to 0 if none that year
prof_year_pubs_citations$count_pubs <- ifelse(is.na(prof_year_pubs_citations$count_pubs),
0,
prof_year_pubs_citations$count_pubs)
```
For each prof, get the first publication year and merge with the rest:
```{r}
# get professor entry years
prof_entry_year <- oa_prof_pubs_unique %>%
filter(publication_year >= 1973 & publication_year <= 2023 &
type %in% c("article", "book", "book-chapter"))%>%
group_by(profile_id)%>%
slice(which.min(publication_year))%>%
select(profile_id, publication_year)
# rename
colnames(prof_entry_year)[2] <- "first_pub"
# merge
prof_year_pubs_citations <- merge(prof_year_pubs_citations,
prof_entry_year,
all.x = TRUE,
by = "profile_id")
# get indicator of years since first pub
prof_year_pubs_citations$years_since_first_pub <- prof_year_pubs_citations$year - prof_year_pubs_citations$first_pub
```
Merge this with professor gender:
```{r}
prof_gender <- dbReadTable(con, "gender_table")
prof_year_pubs_citations <- merge(prof_year_pubs_citations,
prof_gender[c("profile_id", "inferred_gender")],
all.x = TRUE,
by = "profile_id")
```
Write this out:
```{r}
write_csv(prof_year_pubs_citations, "panel_datasets/prof_year_pubs_citations_26_7.csv")
```
# Grant information
Get all the grant information:
```{r}
nwo_grants <- dbReadTable(con, "narcis_nwo_grant_info")
erc_grants <- dbReadTable(con, "erc_grant_info")
```
Get this into a binary format:
```{r}
# for NWO
nwo_grants$veni <- ifelse(nwo_grants$grant == "veni", 1, 0)
nwo_grants$vidi <- ifelse(nwo_grants$grant == "vidi", 1, 0)
nwo_grants$vici <- ifelse(nwo_grants$grant == "vici", 1, 0)
nwo_grants$spinoza <- ifelse(nwo_grants$grant == "spinoza", 1, 0)
nwo_grants$stevin <- ifelse(nwo_grants$grant == "stevin", 1, 0)
# select only the necessary columns
nwo_grants <- nwo_grants %>%
select(year:stevin)
# any grant
nwo_grants$any_nwo <- ifelse(rowSums(nwo_grants[, 3:7]) > 0, 1, 0)
# for ERC
erc_grants$advanced <- ifelse(erc_grants$grant == "Advanced grants", 1, 0)
erc_grants$consolidator <- ifelse(erc_grants$grant == "Consolidator grants", 1, 0)
erc_grants$starting <- ifelse(erc_grants$grant == "Starting grants", 1, 0)
erc_grants$synergy <- ifelse(erc_grants$grant == "Synergy grants", 1, 0)
# select only the necessary columns
erc_grants <- erc_grants %>%
select(profile_id:synergy)
# any grant
erc_grants$any_erc <- ifelse(rowSums(erc_grants[, 3:6]) > 0, 1, 0)
```
Accumulate grants, make sure there are no duplicates, and arrange nicely:
```{r}
nwo_cumulative <- nwo_grants %>%
filter(year >= 1973 & year <= 2023)%>%
arrange(profile_id, year)%>%
group_by(profile_id)%>%
mutate(nwo_total = cumsum(any_nwo))%>%
distinct(profile_id, year, .keep_all = TRUE)
erc_cumulative <- erc_grants %>%
filter(year >= 1973 & year <= 2023)%>%
arrange(profile_id, year)%>%
group_by(profile_id)%>%
mutate(erc_total = cumsum(any_erc))%>%
distinct(profile_id,year, .keep_all = TRUE)
```
Combine this with pubs and citations:
```{r}
prof_year_pubs_citations_grants <- merge(prof_year_pubs_citations,
nwo_cumulative,
all.x = TRUE,
by = c("profile_id", "year"))
prof_year_pubs_citations_grants <- merge(prof_year_pubs_citations_grants,
erc_cumulative,
all.x = TRUE,
by = c("profile_id", "year"))
# replace NAs
prof_year_pubs_citations_grants <- prof_year_pubs_citations_grants %>%
mutate_at(vars(veni:erc_total), ~replace_na(., 0))
```
Write this out:
```{r}
write_csv(prof_year_pubs_citations_grants, "panel_datasets/prof_year_pubs_citations_grants_26_7.csv")
```
```{r}
gc()
rm(erc_grants)
rm(erc_cumulative)
rm(nwo_cumulative)
rm(nwo_grants)
```
# Altmetric attention
Get all the attention measures we have per paper:
```{r}
attention_news <- dbReadTable(con, "altmetric_pub_att_news")
attention_blogs <- dbReadTable(con, "altmetric_pub_att_blogs")
# merge the papers with their authors
attention_news_profs <- merge(attention_news,
oa_prof_pub_matching[c("id", "profile_id")],
by = "id")
# merge the papers with their authors
attention_blogs_profs <- merge(attention_blogs,
oa_prof_pub_matching[c("id", "profile_id")],
by = "id")
```
Compile the two attention sources together:
```{r}
attention_news_profs <- attention_news_profs[c("id", "title", "url", "license", "posted_on",
"summary", "author_name", "author_url", "profile_id")]
attention_blogs_profs <- attention_blogs_profs[c("id", "title", "url", "license", "posted_on",
"summary", "author_name", "author_url", "profile_id")]
attention_news_blogs_profs <- rbind(attention_news_profs,
attention_blogs_profs)
```
Load in news mentions with full text ("response" not an error, but 200 for success)
and match to professors, seeking if their last name is mentioned here:
```{r}
attention_news_full <- dbGetQuery(con, "select * from pub_att_news_full_text where \"response\"='200'")
attention_news_full_match <- merge(attention_news_full,
attention_news_blogs_profs[c("url", "profile_id", "id")],
by = c("url"))
# merge this with professor last names
attention_news_full_match <- merge(attention_news_full_match,
narcis_prof_info[c("profile_id", "last", "first")],
by = "profile_id")
# remove the duplicates
attention_news_full_match$dupl <- duplicated(attention_news_full_match[c("url", "id", "profile_id")])
attention_news_full_match <- attention_news_full_match %>%
filter(dupl == FALSE)%>%
select(-dupl)
attention_news_full_match$first_last <- paste(attention_news_full_match$first, attention_news_full_match$last)
```
Seek professor last name mentions in the full texts of news articles:
```{r}
attention_news_full_match$last_name_mention <- str_detect(tolower(attention_news_full_match$content), paste0("\\b", attention_news_full_match$last, "\\b"))
attention_news_full_match$first_last_mention <- str_detect(tolower(attention_news_full_match$content), paste0("\\b", attention_news_full_match$first_last, "\\b"))
keyword_list_1 <- c("hoogleraar", "universitair docent", "universitair hoofddocent", "assistant professor", "associate professor",
"onderzoeker", "researcher", "universiteitshoogleraar", "professor")
keyword_list_1 <- paste(paste0("\\b", keyword_list_1, "\\b"), collapse ="|")
keyword_list_final <- paste(keyword_list_1, paste(c("^\\bwetenschap", "^\\bscien", "^\\buniversit",
"\\bdr\\.", "\\bprof\\."), collapse = "|"), collapse = "|")
attention_news_full_match$keyword <- str_detect(tolower(attention_news_full_match$content), keyword_list_final)
# both name and keyword!
attention_news_full_match$first_last_key <- ifelse(attention_news_full_match$first_last_mention == TRUE &
attention_news_full_match$keyword == TRUE,
TRUE,
FALSE)
```
Merge the name mentions with the rest of the data:
```{r}
attention_news_blogs_profs_names <- merge(attention_news_blogs_profs,
attention_news_full_match[c("profile_id", "url", "id",
"last_name_mention", "first_last_mention")],
by = c("profile_id","url", "id"),
all.x = TRUE)
```
Classify news attention:
```{r}
# load the classification objects
source("resources/altmetric_news_outlet_classification.R")
attention_news_blogs_profs_names$source_type <- NA
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_aggregator,
"news_aggregator",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_sci_aggregator,
"sci_news_aggregator",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_finance,
"finance_news",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_general,
"general_interest_news",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_general_local,
"general_interest_local_news",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_medical,
"medical_news",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_pop_sci,
"popsci_news",
attention_news_blogs_profs_names$source_type)
attention_news_blogs_profs_names$source_type <- ifelse(attention_news_blogs_profs_names$author_name %in% att_news_sci_portal,
"science_news",
attention_news_blogs_profs_names$source_type)
# if nothing yet, check for blogs
blog_names <- unique(attention_blogs$author_name)
attention_news_blogs_profs_names$source_type <- ifelse((is.na(attention_news_blogs_profs_names$source_type) & attention_news_blogs_profs_names$author_name %in% blog_names),
"online_blog",
attention_news_blogs_profs_names$source_type)
# if nothing yet, set as other
attention_news_blogs_profs_names$source_type <- ifelse(is.na(attention_news_blogs_profs_names$source_type),
"other_news",
attention_news_blogs_profs_names$source_type)
```
Write this out into the database:
```{r}
dbWriteTable(con, "altmetric_att_prepared", attention_news_blogs_profs_names)
```
Compile the attention per professor per year:
```{r}
# get a year from the "posted on" string
attention_news_blogs_profs_names$year <- year(as_date(attention_news_blogs_profs_names$posted_on))
prof_year_attention_online <- attention_news_blogs_profs_names %>%
filter(year >= 2011 & year <= 2023)%>%
group_by(profile_id, source_type, year)%>%
summarise(alt_attn = n())%>%
arrange(profile_id, source_type, year)%>%
pivot_wider(names_from = source_type, values_from = c(alt_attn))%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year)
colnames(prof_year_attention_online)[-c(1:2)] <- paste0("alt_", colnames(prof_year_attention_online)[-c(1:2)])
```
Do the same, but deduplicating multiple paper mentions in single news articles:
```{r}
prof_year_attention_online_dedupe <- attention_news_blogs_profs_names %>%
filter(year >= 2011 & year <= 2023)%>%
distinct(profile_id, url, title, posted_on, author_name,.keep_all = TRUE)%>%
group_by(profile_id, source_type, year)%>%
summarise(alt_attn = n())%>%
arrange(profile_id, source_type, year)%>%
pivot_wider(names_from = source_type, values_from = c(alt_attn))%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year)
colnames(prof_year_attention_online_dedupe)[-c(1:2)] <- paste0("alt_ded_", colnames(prof_year_attention_online_dedupe)[-c(1:2)])
# rearrange to match the column order of the other dataframe above
prof_year_attention_online_dedupe <- prof_year_attention_online_dedupe[c("profile_id", "year", "alt_ded_news_aggregator", "alt_ded_online_blog", "alt_ded_sci_news_aggregator" , "alt_ded_finance_news" , "alt_ded_general_interest_local_news", "alt_ded_general_interest_news", "alt_ded_medical_news", "alt_ded_other_news", "alt_ded_popsci_news", "alt_ded_science_news")]
```
Do the same only for those where we have names last included:
```{r}
prof_year_attention_online_names <- attention_news_blogs_profs_names %>%
filter(year >= 2011 & year <= 2023 & last_name_mention == TRUE)%>%
group_by(profile_id, source_type, year)%>%
summarise(alt_attn = n())%>%
arrange(profile_id, source_type, year)%>%
pivot_wider(names_from = source_type, values_from = c(alt_attn))%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year)
colnames(prof_year_attention_online_names)[-c(1:2)] <- paste0("alt_name_", colnames(prof_year_attention_online_names)[-c(1:2)])
# rearrange to match the column order of the other dataframe above
prof_year_attention_online_names <- prof_year_attention_online_names[c("profile_id", "year", "alt_name_news_aggregator", "alt_name_online_blog", "alt_name_sci_news_aggregator" , "alt_name_finance_news" , "alt_name_general_interest_local_news", "alt_name_general_interest_news", "alt_name_medical_news", "alt_name_other_news", "alt_name_popsci_news", "alt_name_science_news")]
```
And for the full name included:
```{r}
prof_year_attention_online_full_names <- attention_news_blogs_profs_names %>%
filter(year >= 2011 & year <= 2023 & first_last_mention == TRUE)%>%
group_by(profile_id, source_type, year)%>%
summarise(alt_attn = n())%>%
arrange(profile_id, source_type, year)%>%
pivot_wider(names_from = source_type, values_from = c(alt_attn))%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year)
colnames(prof_year_attention_online_full_names)[-c(1:2)] <- paste0("alt_fname_", colnames(prof_year_attention_online_full_names)[-c(1:2)])
# rearrange to match the column order of the other dataframe above
prof_year_attention_online_full_names <- prof_year_attention_online_full_names[c("profile_id", "year", "alt_fname_news_aggregator", "alt_fname_online_blog", "alt_fname_sci_news_aggregator" , "alt_fname_finance_news" , "alt_fname_general_interest_local_news", "alt_fname_general_interest_news", "alt_fname_medical_news", "alt_fname_other_news", "alt_fname_popsci_news", "alt_fname_science_news")]
```
And now only for single-authored papers:
```{r}
prof_year_attention_online_single_au <- attention_news_blogs_profs_names %>%
filter(year >= 2011 & year <= 2023 & id %in% oa_prof_pubs_unique_single_au$id)%>%
distinct(profile_id, url, title, posted_on, author_name,.keep_all = TRUE)%>%
group_by(profile_id, source_type, year)%>%
summarise(alt_attn = n())%>%
arrange(profile_id, source_type, year)%>%
pivot_wider(names_from = source_type, values_from = c(alt_attn))%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year)
colnames(prof_year_attention_online_single_au)[-c(1:2)] <- paste0("alt_single_", colnames(prof_year_attention_online_single_au)[-c(1:2)])
prof_year_attention_online_single_au <- prof_year_attention_online_single_au[c("profile_id", "year", "alt_single_news_aggregator", "alt_single_online_blog", "alt_single_sci_news_aggregator" , "alt_single_finance_news" , "alt_single_general_interest_local_news", "alt_single_general_interest_news", "alt_single_medical_news", "alt_single_other_news", "alt_single_popsci_news", "alt_single_science_news")]
```
Merge the attention with the rest:
```{r}
prof_year_p_c_g_a <- merge(prof_year_pubs_citations_grants,
prof_year_attention_online,
by = c("profile_id", "year"),
all.x = TRUE)
prof_year_p_c_g_a <- merge(prof_year_p_c_g_a,
prof_year_attention_online_dedupe,
by = c("profile_id", "year"),
all.x = TRUE)
prof_year_p_c_g_a <- merge(prof_year_p_c_g_a,
prof_year_attention_online_single_au,
by = c("profile_id", "year"),
all.x = TRUE)
prof_year_p_c_g_a <- merge(prof_year_p_c_g_a,
prof_year_attention_online_names,
by = c("profile_id", "year"),
all.x = TRUE)
prof_year_p_c_g_a <- merge(prof_year_p_c_g_a,
prof_year_attention_online_full_names,
by = c("profile_id", "year"),
all.x = TRUE)
# get the cumulatives
# As Altmetric data goes back to 2011 in principle, set attention to 0 if year >= 2011, leave as NA
# otherwise:
prof_year_p_c_g_a <- prof_year_p_c_g_a %>%
arrange(profile_id, year)%>%
mutate_at(vars(contains('alt_')), ~ifelse(is.na(.), 0, .))%>%
group_by(profile_id)%>%
mutate(across(alt_news_aggregator:alt_fname_science_news, ~cumsum(.x), .names = "{col}_total"))%>%
mutate_at(vars(contains('alt_')), ~ifelse(. == 0 & year < 2011, NA, .))
```
Combine this with Twitter attention, which we only obtain using ORCIDs (for now).
```{r}
twitter_orcid_attention <- dbGetQuery(con, statement = "select * from altmetric_prof_attention where \"mention_type\"='tweet'")
# rename the columns and get cumulatives
twitter_orcid_attention <- twitter_orcid_attention %>%
select(profile_id, year, yearly_count)
colnames(twitter_orcid_attention)[which(colnames(twitter_orcid_attention) == "yearly_count")] <- "alt_twitter"
prof_year_p_c_g_a <- merge(prof_year_p_c_g_a,
twitter_orcid_attention,
by = c("profile_id", "year"),
all.x = TRUE)
prof_year_p_c_g_a <- prof_year_p_c_g_a %>%
arrange(profile_id, year)%>%
mutate_at(vars(contains('twitter')), ~ifelse(is.na(.), 0, .))%>%
group_by(profile_id)%>%
mutate(across(alt_twitter, ~cumsum(.x), .names = "{col}_total"))%>%
mutate_at(vars(contains('twitter')), ~ifelse(. == 0 & year < 2011, NA, .))
```
Get total altmetrics as well as totals of "general interest" outlets:
```{r}
prof_year_p_c_g_a$alt_online_all <- rowSums(prof_year_p_c_g_a[,c("alt_news_aggregator",
"alt_online_blog",
"alt_sci_news_aggregator",
"alt_finance_news",
"alt_general_interest_local_news",
"alt_general_interest_news",
"alt_medical_news",
"alt_other_news",
"alt_popsci_news",
"alt_science_news")])
prof_year_p_c_g_a$alt_online_ded_all <- rowSums(prof_year_p_c_g_a[,c("alt_ded_news_aggregator",
"alt_ded_online_blog",
"alt_ded_sci_news_aggregator",
"alt_ded_finance_news",
"alt_ded_general_interest_local_news",
"alt_ded_general_interest_news",
"alt_ded_medical_news",
"alt_ded_other_news",
"alt_ded_popsci_news",
"alt_ded_science_news")])
prof_year_p_c_g_a$alt_online_name_all <- rowSums(prof_year_p_c_g_a[,c("alt_name_news_aggregator",
"alt_name_online_blog",
"alt_name_sci_news_aggregator",
"alt_name_finance_news",
"alt_name_general_interest_local_news",
"alt_name_general_interest_news",
"alt_name_medical_news",
"alt_name_other_news",
"alt_name_popsci_news",
"alt_name_science_news")])
prof_year_p_c_g_a$alt_online_fname_all <- rowSums(prof_year_p_c_g_a[,c("alt_fname_news_aggregator",
"alt_fname_online_blog",
"alt_fname_sci_news_aggregator",
"alt_fname_finance_news",
"alt_fname_general_interest_local_news",
"alt_fname_general_interest_news",
"alt_fname_medical_news",
"alt_fname_other_news",
"alt_fname_popsci_news",
"alt_fname_science_news")])
prof_year_p_c_g_a$alt_online_single_all <- rowSums(prof_year_p_c_g_a[,c("alt_single_news_aggregator",
"alt_single_online_blog",
"alt_single_sci_news_aggregator",
"alt_single_finance_news",
"alt_single_general_interest_local_news",
"alt_single_general_interest_news",
"alt_single_medical_news",
"alt_single_other_news",
"alt_single_popsci_news",
"alt_single_science_news")])
prof_year_p_c_g_a$alt_online_all_total <- rowSums(prof_year_p_c_g_a[,c("alt_news_aggregator_total",
"alt_online_blog_total",
"alt_sci_news_aggregator_total",
"alt_finance_news_total",
"alt_general_interest_local_news_total",
"alt_general_interest_news_total",
"alt_medical_news_total",
"alt_other_news_total",
"alt_popsci_news_total",
"alt_science_news_total")])
prof_year_p_c_g_a$alt_online_ded_all_total <- rowSums(prof_year_p_c_g_a[,c("alt_ded_news_aggregator_total",
"alt_ded_online_blog_total",
"alt_ded_sci_news_aggregator_total",
"alt_ded_finance_news_total",
"alt_ded_general_interest_local_news_total",
"alt_ded_general_interest_news_total",
"alt_ded_medical_news_total",
"alt_ded_other_news_total",
"alt_ded_popsci_news_total",
"alt_ded_science_news_total")])
prof_year_p_c_g_a$alt_online_name_all_total <- rowSums(prof_year_p_c_g_a[,c("alt_name_news_aggregator_total",
"alt_name_online_blog_total",
"alt_name_sci_news_aggregator_total",
"alt_name_finance_news_total",
"alt_name_general_interest_local_news_total",
"alt_name_general_interest_news_total",
"alt_name_medical_news_total",
"alt_name_other_news_total",
"alt_name_popsci_news_total",
"alt_name_science_news_total")])
prof_year_p_c_g_a$alt_online_fname_all_total <- rowSums(prof_year_p_c_g_a[,c("alt_fname_news_aggregator_total",
"alt_fname_online_blog_total",
"alt_fname_sci_news_aggregator_total",
"alt_fname_finance_news_total",
"alt_fname_general_interest_local_news_total",
"alt_fname_general_interest_news_total",
"alt_fname_medical_news_total",
"alt_fname_other_news_total",
"alt_fname_popsci_news_total",
"alt_fname_science_news_total")])
prof_year_p_c_g_a$alt_online_single_all_total <- rowSums(prof_year_p_c_g_a[,c("alt_single_news_aggregator_total",
"alt_single_online_blog_total",
"alt_single_sci_news_aggregator_total",
"alt_single_finance_news_total",
"alt_single_general_interest_local_news_total",
"alt_single_general_interest_news_total",
"alt_single_medical_news_total",
"alt_single_other_news_total",
"alt_single_popsci_news_total",
"alt_single_science_news_total")])
prof_year_p_c_g_a$alt_online_general_all <- rowSums(prof_year_p_c_g_a[,c(
"alt_finance_news",
"alt_general_interest_local_news",
"alt_general_interest_news",
"alt_popsci_news")])
prof_year_p_c_g_a$alt_online_general_ded_all <- rowSums(prof_year_p_c_g_a[,c(
"alt_ded_finance_news",
"alt_ded_general_interest_local_news",
"alt_ded_general_interest_news",
"alt_ded_popsci_news")])
prof_year_p_c_g_a$alt_online_general_name_all <- rowSums(prof_year_p_c_g_a[,c(
"alt_name_finance_news",
"alt_name_general_interest_local_news",
"alt_name_general_interest_news",
"alt_name_popsci_news")])
prof_year_p_c_g_a$alt_online_general_fname_all <- rowSums(prof_year_p_c_g_a[,c(
"alt_fname_finance_news",
"alt_fname_general_interest_local_news",
"alt_fname_general_interest_news",
"alt_fname_popsci_news")])
prof_year_p_c_g_a$alt_online_general_single_all <- rowSums(prof_year_p_c_g_a[,c(
"alt_single_finance_news",
"alt_single_general_interest_local_news",
"alt_single_general_interest_news",
"alt_single_popsci_news")])
prof_year_p_c_g_a$alt_online_general_all_total <- rowSums(prof_year_p_c_g_a[,c(
"alt_finance_news_total",
"alt_general_interest_local_news_total",
"alt_general_interest_news_total",
"alt_popsci_news_total")])
prof_year_p_c_g_a$alt_online_general_ded_all_total <- rowSums(prof_year_p_c_g_a[,c(
"alt_ded_finance_news_total",
"alt_ded_general_interest_local_news_total",
"alt_ded_general_interest_news_total",
"alt_ded_popsci_news_total")])
prof_year_p_c_g_a$alt_online_general_name_all_total <- rowSums(prof_year_p_c_g_a[,c(
"alt_name_finance_news_total",
"alt_name_general_interest_local_news_total",
"alt_name_general_interest_news_total",
"alt_name_popsci_news_total")])
prof_year_p_c_g_a$alt_online_general_fname_all_total <- rowSums(prof_year_p_c_g_a[,c(
"alt_fname_finance_news_total",
"alt_fname_general_interest_local_news_total",
"alt_fname_general_interest_news_total",
"alt_fname_popsci_news_total")])
prof_year_p_c_g_a$alt_online_general_single_all_total <- rowSums(prof_year_p_c_g_a[,c(
"alt_single_finance_news_total",
"alt_single_general_interest_local_news_total",
"alt_single_general_interest_news_total",
"alt_single_popsci_news_total")])
```
Write this out:
```{r}
write_csv(prof_year_p_c_g_a, "panel_datasets/prof_year_pubs_citations_grants_alt_26_7.csv")
```
Clear the memory, remove some redundant objects:
```{r}
rm(twitter_orcid_attention)
rm(attention_blogs)
rm(attention_blogs_profs)
rm(attention_news)
rm(attention_news_blogs_profs)
rm(attention_news_blogs_profs_names)
rm(latest_citation)
gc()
```
# Printed news attention
Load the lexis articles, filter out the irrelevant ones and drop the regional
publication duplicates:
```{r}
lexis_data <- dbReadTable(con, "lexis_nexis_mentions")
```
Now, aggregate professor mentions per year and per source, wherever relevant:
```{r}
# combine sources for easier handling:
prof_news_year <- lexis_data %>%
filter(!is.na(year) & year >= 1973 & year <= 2023)%>%
arrange(profile_id, year)%>%
group_by(profile_id, year, source_type)%>%
summarise(n = n())%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year, source_type)%>%
group_by(profile_id, source_type)%>%
mutate(cumsum = cumsum(n))%>%
pivot_wider(names_from = source_type, values_from = c(n, cumsum))%>%
fill(cumsum_national_nl:cumsum_high_prof_intl)%>%
replace(is.na(.), 0)
prof_news_year <- prof_news_year[c("profile_id", "year", "n_national_nl",
"n_news_aggr", "n_finance", "n_other",
"n_regional_nl", "n_science", "n_prof",
"n_local_int", "n_unknown", "n_high_prof_intl",
"n_other_int", "n_blog", "cumsum_national_nl",
"cumsum_news_aggr", "cumsum_finance", "cumsum_other",
"cumsum_regional_nl", "cumsum_science", "cumsum_prof",
"cumsum_local_int", "cumsum_unknown", "cumsum_high_prof_intl",
"cumsum_other_int", "cumsum_blog" )]
# tidy up the columns
colnames(prof_news_year)[3:26] <- c("news_national", "news_aggr", "news_finance",
"news_other", "news_regional", "news_science",
"news_professional", "news_local_intl", "news_unknown",
"news_intl", "news_intl_other", "news_blog",
"news_national_total", "news_aggr_total", "news_finance_total",
"news_other_total", "news_regional_total", "news_science_total",
"news_professional_total", "news_local_intl_total", "news_unknown_total",
"news_intl_total", "news_intl_other_total", "news_blog_total")
# add total counts
prof_news_year$news_all <- rowSums(prof_news_year[3:14])
prof_news_year$news_all_total <- rowSums(prof_news_year[15:26])
# add general interest counts
prof_news_year$news_general_all <- rowSums(prof_news_year[c("news_national", "news_regional", "news_intl",
"news_local_intl", "news_intl_other")])
prof_news_year$news_general_all_total <- rowSums(prof_news_year[c("news_national_total", "news_regional_total", "news_intl_total",
"news_local_intl_total", "news_intl_other_total")])
# rearrange a bit
prof_news_year <- prof_news_year %>%
select(profile_id, year, news_national, news_regional, news_intl, news_local_intl,
news_intl_other, news_general_all, news_finance, news_professional, news_science, news_blog,
news_aggr, news_unknown, news_other, news_all,
news_national_total, news_regional_total,
news_intl_total, news_local_intl_total, news_intl_other_total, news_general_all_total,
news_finance_total, news_professional_total, news_science_total, news_blog_total,
news_aggr_total, news_unknown_total, news_other_total, news_all_total)
```
Deduplicated regional news:
```{r}
# combine sources for easier handling:
prof_news_year_ded <- lexis_data %>%
filter(!is.na(year) & year >= 1973 & year <= 2023 & regional_duplicate == FALSE)%>%
arrange(profile_id, year)%>%
group_by(profile_id, year, source_type)%>%
summarise(n = n())%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year, source_type)%>%
group_by(profile_id, source_type)%>%
mutate(cumsum = cumsum(n))%>%
pivot_wider(names_from = source_type, values_from = c(n, cumsum))%>%
fill(cumsum_national_nl:cumsum_high_prof_intl)%>%
replace(is.na(.), 0)
prof_news_year_ded <- prof_news_year_ded[c("profile_id", "year", "n_national_nl",
"n_news_aggr", "n_finance", "n_other",
"n_regional_nl", "n_science", "n_prof",
"n_local_int", "n_unknown", "n_high_prof_intl",
"n_other_int", "n_blog", "cumsum_national_nl",
"cumsum_news_aggr", "cumsum_finance", "cumsum_other",
"cumsum_regional_nl", "cumsum_science", "cumsum_prof",
"cumsum_local_int", "cumsum_unknown", "cumsum_high_prof_intl",
"cumsum_other_int", "cumsum_blog" )]
# tidy up the columns
colnames(prof_news_year_ded)[3:26] <- c("news_ded_national", "news_ded_aggr", "news_ded_finance",
"news_ded_other", "news_ded_regional", "news_ded_science",
"news_ded_professional", "news_ded_local_intl", "news_ded_unknown",
"news_ded_intl", "news_ded_intl_other", "news_ded_blog",
"news_ded_national_total", "news_ded_aggr_total", "news_ded_finance_total",
"news_ded_other_total", "news_ded_regional_total", "news_ded_science_total",
"news_ded_professional_total", "news_ded_local_intl_total", "news_ded_unknown_total",
"news_ded_intl_total", "news_ded_intl_other_total", "news_ded_blog_total")
# add total counts
prof_news_year_ded$news_ded_all <- rowSums(prof_news_year_ded[3:14])
prof_news_year_ded$news_ded_all_total <- rowSums(prof_news_year_ded[15:26])
# add general interest counts
prof_news_year_ded$news_ded_general_all <- rowSums(prof_news_year_ded[c("news_ded_national", "news_ded_regional", "news_ded_intl",
"news_ded_local_intl", "news_ded_intl_other")])
prof_news_year_ded$news_ded_general_all_total <- rowSums(prof_news_year_ded[c("news_ded_national_total", "news_ded_regional_total",
"news_ded_intl_total", "news_ded_local_intl_total",
"news_ded_intl_other_total")])
# rearrange a bit
prof_news_year_ded <- prof_news_year_ded %>%
select(profile_id, year, news_ded_regional, news_ded_general_all, news_ded_all,
news_ded_regional_total, news_ded_general_all_total, news_ded_all_total)
```
Do the same, but excluding online resources:
```{r}
prof_news_year_offline <- lexis_data %>%
filter(!is.na(year) & year >= 1973 & year <= 2023 & online_resource == FALSE)%>%
arrange(profile_id, year)%>%
group_by(profile_id, year, source_type)%>%
summarise(n = n())%>%
replace(is.na(.), 0)%>%
arrange(profile_id, year, source_type)%>%
group_by(profile_id, source_type)%>%
mutate(cumsum = cumsum(n))%>%
pivot_wider(names_from = source_type, values_from = c(n, cumsum))%>%
fill(cumsum_national_nl:cumsum_high_prof_intl)%>%
replace(is.na(.), 0)
prof_news_year_offline <- prof_news_year_offline[c("profile_id", "year", "n_national_nl",
"n_news_aggr", "n_finance", "n_other",
"n_regional_nl", "n_science", "n_prof",
"n_local_int", "n_unknown", "n_high_prof_intl",
"n_other_int", "n_blog", "cumsum_national_nl",
"cumsum_news_aggr", "cumsum_finance", "cumsum_other",
"cumsum_regional_nl", "cumsum_science", "cumsum_prof",
"cumsum_local_int", "cumsum_unknown", "cumsum_high_prof_intl",
"cumsum_other_int", "cumsum_blog" )]
# tidy up the columns
colnames(prof_news_year_offline)[3:26] <- c("news_off_national", "news_off_aggr", "news_off_finance",
"news_off_other", "news_off_regional", "news_off_science",
"news_off_professional", "news_off_local_intl", "news_off_unknown",
"news_off_intl", "news_off_intl_other", "news_off_blog",
"news_off_national_total", "news_off_aggr_total", "news_off_finance_total",
"news_off_other_total", "news_off_regional_total", "news_off_science_total",
"news_off_professional_total", "news_off_local_intl_total", "news_off_unknown_total",
"news_off_intl_total", "news_off_intl_other_total", "news_off_blog_total")
# add total counts
prof_news_year_offline$news_off_all <- rowSums(prof_news_year_offline[3:14])
prof_news_year_offline$news_off_all_total <- rowSums(prof_news_year_offline[15:26])
# add general interest counts
prof_news_year_offline$news_off_general_all <- rowSums(prof_news_year_offline[c("news_off_national", "news_off_regional", "news_off_intl",
"news_off_local_intl", "news_off_intl_other")])
prof_news_year_offline$news_off_general_all_total <- rowSums(prof_news_year_offline[c("news_off_national_total",