This lab journal replicates table 2.


1 Custom functions

  • fpackage.check: Check if packages are installed (and install if not) in R (source).
rm(list = ls())

fpackage.check <- function(packages) {
    lapply(packages, FUN = function(x) {
        if (!require(x, character.only = TRUE)) {
            install.packages(x, dependencies = TRUE)
            library(x, character.only = TRUE)
        }
    })
}

2 Packages

  • tidyverse: tidy data manipulations
  • kableExtra: creating tables in consistent formatting
packages = c("tidyverse", "kableExtra")

fpackage.check(packages)

3 Input

We use one processed dataset.

load(file = "./data/processed/df_stopping.rda")

4 Table 2

columns <- c("Min", "Max", "Mean", "SD")

rows <- c("Gender", "Man", "Woman", "Missing", "Ethnicity", "Ethnic majority", "Ethnic minority", "Other",
    "University", "Erasmus University", "Leiden University", "Radboud University", "University of Groningen",
    "Delft University of Technology", "Eindhoven University of Technology", "Tilburg University", "Maastricht University",
    "University of Twente", "Utrecht University", "University of Amsterdam", "Vrije Universiteit Amsterdam",
    "Wageningen University and Research Centre", "Field", "Biological and health sciences", "Physical and mathematical sciences",
    "Social and behavioural sciences", "Engineering", "Agricultural sciences", "Humanities", "Missing ",
    "<strong>PhD Cohort</strong></p>", "<strong>Previous publications</strong></p> <sup>a</sup></var>",
    "<strong>Stopping to publish</strong></p>", "Source: Dutch Doctoral Recipients (D-cubed) data 1990-2018")


t2 <- data.frame(matrix(nrow = length(rows), ncol = length(columns)))
colnames(t2) <- columns
rownames(t2) <- rows

df_ppf3[!duplicated(df_ppf3$id), ] -> sample

t2[c(2:4), 3] <- prop.table(table(sample$gender))[1:3]
t2[c(6:8), 3] <- prop.table(table(sample$ethnicity2))[1:3]
t2[c(10:22), 3] <- prop.table(table(sample$uni))[1:13]
t2[c(24:30), 3] <- prop.table(table(sample$field2))[1:7]
t2[31, c(1:3)] <- summary(sample$phd_cohort)[c(1, 6, 4)]
t2[31, 4] <- sd(sample$phd_cohort)
t2[32, c(1:3)] <- summary(df_ppf3$npubs_prev_s)[c(1, 6, 4)]
t2[32, 4] <- sd(df_ppf3$npubs_prev_s)
t2[33, 3] <- prop.table(table(df_ppf3$inactive))[2]


t2[c(2:4, 6:8, 10:22, 24:30, 33), c(1, 2)] <- c(rep(0, times = 27), rep(1, times = 27))  # binary variables min/max

t2[c(2:4, 6:8, 10:22, 24:33), 3] <- format(round(t2[c(2:4, 6:8, 10:22, 24:33), 3], 2), nsmall = 2)  # rounding to 2 decimals

t2[c(31, 32), c(1, 2, 4)] <- format(round(t2[c(31, 32), c(1, 2, 4)], 2), nsmall = 2)  # rounding

t2[is.na(t2)] <- ""


# N
nrow(sample)
#> [1] 15021
t2 %>%
    kable(format = "html", caption = "<b>Table 2.</b> Descriptive statistics for analyses `stopping to publish` (N=15,021)",
        escape = FALSE) %>%
    row_spec(row = 34, italic = T) %>%
    row_spec(row = c(1, 5, 9, 23), bold = T) %>%
    kable_classic(full_width = F, html_font = "Cambria") %>%
    footnote(alphabet = "Summary statistics for 'previous publications' are calculated at the level of person-periods, instead of at the level of individuals") %>%
    kable_styling(font_size = 14) -> table2

table2
Table 2. Descriptive statistics for analyses stopping to publish (N=15,021)
Min Max Mean SD
Gender
Man 0 1 0.44
Woman 0 1 0.34
Missing 0 1 0.22
Ethnicity
Ethnic majority 0 1 0.67
Ethnic minority 0 1 0.02
Other 0 1 0.32
University
Erasmus University 0 1 0.04
Leiden University 0 1 0.03
Radboud University 0 1 0.19
University of Groningen 0 1 0.02
Delft University of Technology 0 1 0.01
Eindhoven University of Technology 0 1 0.01
Tilburg University 0 1 0.01
Maastricht University 0 1 0.09
University of Twente 0 1 0.12
Utrecht University 0 1 0.13
University of Amsterdam 0 1 0.10
Vrije Universiteit Amsterdam 0 1 0.09
Wageningen University and Research Centre 0 1 0.16
Field
Biological and health sciences 0 1 0.36
Physical and mathematical sciences 0 1 0.15
Social and behavioural sciences 0 1 0.13
Engineering 0 1 0.10
Agricultural sciences 0 1 0.09
Humanities 0 1 0.03
Missing 0 1 0.14
PhD Cohort 0.00 28.00 18.46 7.04
Previous publications a 0.00 2.05 0.48 0.30
Stopping to publish 0 1 0.08
Source: Dutch Doctoral Recipients (D-cubed) data 1990-2018
a Summary statistics for ‘previous publications’ are calculated at the level of person-periods, instead of at the level of individuals

LS0tDQp0aXRsZTogIlRhYmxlIDIiDQpkYXRlOiAiTGFzdCBjb21waWxlZCBvbiBgciBmb3JtYXQoU3lzLnRpbWUoKSwgJyVCLCAlWScpYCINCm91dHB1dDogDQogIGh0bWxfZG9jdW1lbnQ6DQogICAgY3NzOiB0d2Vha3MuY3NzDQogICAgdG9jOiAgdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KICAgIG51bWJlcl9zZWN0aW9uczogdHJ1ZQ0KICAgIGNvZGVfZm9sZGluZzogc2hvdw0KICAgIGNvZGVfZG93bmxvYWQ6IHllcw0KICAgIA0KLS0tDQoNCg0KYGBge3IsIGdsb2JhbHNldHRpbmdzLCBlY2hvPUZBTFNFLCB3YXJuaW5nPUZBTFNFLCByZXN1bHRzPSJoaWRlIn0NCg0KbGlicmFyeShrbml0cikNCm9wdHNfY2h1bmskc2V0KHRpZHkub3B0cz1saXN0KHdpZHRoLmN1dG9mZj0xMDApLHRpZHk9VFJVRSwgd2FybmluZyA9IEZBTFNFLCBtZXNzYWdlID0gRkFMU0UsY29tbWVudCA9ICIjPiIsIGNhY2hlPVRSVUUsIGNsYXNzLnNvdXJjZT1jKCJ0ZXN0IiksIGNsYXNzLm91dHB1dD1jKCJ0ZXN0MiIpLCBjYWNoZS5sYXp5ID0gRkFMU0UpDQpvcHRpb25zKHdpZHRoID0gMTAwKQ0KcmdsOjpzZXR1cEtuaXRyKCkNCg0KY29sb3JpemUgPC0gZnVuY3Rpb24oeCwgY29sb3IpIHtzcHJpbnRmKCI8c3BhbiBzdHlsZT0nY29sb3I6ICVzOyc+JXM8L3NwYW4+IiwgY29sb3IsIHgpIH0NCg0KYGBgDQoNCmBgYHtyIGtsaXBweSwgZWNobz1GQUxTRSwgaW5jbHVkZT1UUlVFLCBldmFsPVRSVUV9DQprbGlwcHk6OmtsaX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