The NextGen Harmonised Data Gateway
  • Home
  • Variable Database
    • Variable Database
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Harmonisation
    • Harmonisation Toolbox
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Data
  • Training
  • Contact
    • User Support
    • Team

On this page

  • Set-up
  • 1. Prepare Data: EB 2001
  • 2. Prepare Data: ESS 2020
  • 3. Harmonisation
  • Summary

Internet Access Locations

This page guides you through the harmonisation process of the Internet Access Locations item.

The item was administered in EB 2001 and ESS 2020. Before we start harmonising, please download these data sets from the respective repositories. You can find links to the survey repositories on the Make It Digital! data documentation page, in the section devoted to Internet Access Locations. If you click on the single year, the link takes you to the specific data set. We are working with the .sav format. So please make sure to download the datasets in this format.

Set-up

Please download the statistical software R (R Core Team, 2024) and RStudio (RStudio Team, 2023). Then start a project in RStudio by clicking File > New Project and set up a new directory or assign your project to an existing directory (i.e., folder). Within the project directory, create a folder called “data”. Now save the downloaded ESS and EB survey data into this “data” folder. Lastly, please download the following packages using the install.packages() function if they have not been installed before.

install.packages()
packages <- c( "tidyverse", "readxl", "xlsx", "haven", "labelled", "tidyr", "knitr", "kableExtra", "dplyr", "openxlsx")

installed <- packages %in% rownames(installed.packages())
if (any(!installed)) install.packages(packages[!installed])

Every package installed in R must also be loaded. This is what the library-function is for.

library(tidyverse)
library(readxl)
library(openxlsx) # If you have problems installing or loading the xlsx-package, use the openxlsx. 
library(haven)
library(labelled)
library(tidyr)
library(knitr)
library(kableExtra)
library(dplyr)

An important step during the harmonisation process is to prepare the source data sets in a consistent and systematic way. For that, the functions “codebook” (create_codebook_short()) and ”crosswalk table” (create_cwt()) by Kołczyńska (2022) are used. They show the correspondence between source data sets and harmonised data regarding variable names and values. These functions are adopted into our needs and the R file containing them can be downloaded here . Please save this file in the R project folder and import it into the R project via source("kolczynska2022_i4ng.R").

How-to

If you can not download the R-file and if it is opened in a new tab, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the kolczynska2022-file into this new file. Make sure that you save this new file in your project folder under the name “kolczynska2022_i4ng.R”.

source("kolczynska2022_i4ng.R")

Now we can name our target variable as “d_iu_acce”. The name is a combination of “d” representing the main topic “Digital”, the concept “Internet Usage” and the variable label “Internet Access Locations”.

target_var_hrms <- "d_iu_acce"

Both the ESS and EB items are “Tick all that apply” questions. This required harmonisation to be implemented at the data import, rather than in a later harmonisation step. Each response category is transformed into a separate dichotomous variable coded 1 = Marked and 0 = Not marked. The harmonised response categories are: (01) At home, (02) At my workplace, (03) On the move, (04) At some other place (such as a café or a friend’s house), and (05) NA.

1. Prepare Data: EB 2001

Six steps must be carried out in the following coding section:

1.1 Import data

Separate dichotomous variables are created for each of the harmonised response categories. The categories At home (“Q49 INTERNET USE: AT HOME”) and At work (“Q49 INTERNET USE: AT WORK”) are taken directly from the original variables. A combined category, On the move, is created by merging the categories “Q49 INTERNET USE: FROM LAPTOP”, “Q49 INTERNET USE: FROM POCKET COMPUTER”, and “Q49 INTERNET USE: FROM MOBILE PHONE”, coded as 1 if at least one is selected. Another combined category, Other place, is created by merging “Q49 INTERNET USE: AT SCHOOL UNIVERSITY”, “Q49 INTERNET USE: PUBLIC ACCESS POINT”, “Q49 INTERNET USE: IN A CYBERCAFE”, “Q49 INTERNET USE: IN OTHER’S HOUSE”, and “Q49 INTERNET USE: ELSEWHERE”, coded as 1 if at least one is selected. The DK category (“Q49 INTERNET USE: DK”) is retained as a separate variable.

eb <- haven::read_sav("data/ZA3627_v1-0-1.sav", user_na=TRUE) %>% 
  mutate(d_iu_acce_home = v308,
         d_iu_acce_home = labelled_spss(d_iu_acce_home, label = "At home"),
         d_iu_acce_work = v309,
         d_iu_acce_work = labelled_spss(d_iu_acce_work, label = "At work"),
         move = rowSums(across(c(v314, v315, v316), ~.)), # laptop, pocket comp, mobile phone
         d_iu_acce_move = ifelse(move >= 1, 1, 0),
         d_iu_acce_move = labelled_spss(d_iu_acce_move, label = "On the move"),
         othr = rowSums(across(c(v310, v311, v312, v313, v317), ~.)),
         d_iu_acce_othr = ifelse(othr >= 1, 1, 0),
         d_iu_acce_othr = labelled_spss(d_iu_acce_othr, label = "Other place"),
         d_iu_acce_na = v319,
         d_iu_acce_na = labelled_spss(d_iu_acce_na, label = "DK"))
Check the source item

The following codes can be used to check:

# check labels
sapply(eb %>% select(starts_with("d_iu_acce")), var_label)

# checks
eb %>% count(v308, d_iu_acce_home) 
eb %>% count(v309, d_iu_acce_work)
eb %>% count(v314, v315, v316, move, d_iu_acce_move)
print(eb %>% count(v310, v311, v312, v313, v317, othr, d_iu_acce_othr), n=30)
eb %>% count(v319, d_iu_acce_na)

1.2. Create codebook

Not just the substantive variables but also protocol variables need to be selected from this data set. Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. In this step, we create a codebook that provides an overview of the selected variables and their naming in the harmonised data.

codebook_eb <- create_codebook_short(eb %>% select(-move, -othr)) %>% 
  mutate(survey = "EB",
         target_var = ifelse(var_source == "isocntry", "country_source", NA),
         target_var = ifelse(var_source == "v11", "w_poststr", target_var),
         target_var = ifelse(grepl("ORIGINAL RESPONDENT", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(grepl("Q49 INTERNET USE:", var_label_source), var_source, target_var),
         target_var = ifelse(grepl("d_iu_acce", var_source), var_source, target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

codebook_eb includes the columns called: var_source, var_label_source, survey, target_var.

 

1.3. Retrieve names of the chosen source variables

variables <- codebook_eb %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: isocntry, v11, v308, v309, v310, v311, v312, v313, v314, v315, v316, v317, v318, v319, v476, d_iu_acce_home, d_iu_acce_work, d_iu_acce_move, d_iu_acce_othr, d_iu_acce_na.

 

1.4. Select a subset of the survey data containing only the chosen variables

eb_small <- eb %>% select(all_of(variables)) %>% mutate(caseid = row_number())

You will see that the following data set is a subset of the EB 2001 including the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

isocntry v11 v308 v309 v310 v311 v312 v313 v314 v315 v316 v317 v318 v319 v476 d_iu_acce_home d_iu_acce_work d_iu_acce_move d_iu_acce_othr d_iu_acce_na caseid
BE 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 0 0 0 0 0 1
BE 1.0220 0 0 0 0 0 0 0 0 0 0 1 0 10002 0 0 0 0 0 2
BE 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10003 0 0 0 0 0 3
BE 0.8740 0 0 1 0 0 0 0 0 0 0 0 0 10004 0 0 0 1 0 4
BE 0.9289 0 1 0 0 0 0 0 0 0 0 0 0 10005 0 1 0 0 0 5
BE 0.8740 1 0 0 0 0 0 1 0 0 0 0 0 10006 1 0 1 0 0 6

 

1.5. Create a crosswalk table for the chosen variables

A crosswalk table provides a connection between the source variable values and the target variable values. First, it provides the variables, their labels, and the possible values. Then, the information is linked with the codebook information of the newly specified target variables. Lastly, target values are defined in a variable called target_value.

Here, weight and ID variables are excluded from the crosswalk table. Original codes for the country variable are preserved.

eb_cwt <- create_cwt(eb_small %>% select(isocntry, starts_with("d_iu_acce"))) %>%
  left_join(codebook_eb, by = join_by(var_label_source, var_source)) %>%
  mutate(target_value = NA,
         target_value = value_code,
         value_code = as.character(value_code))
Important

The utility of creating a crosswalk table is that the results of these decisions can be seen explicitly by comparing the value_code and target_value columns.

In this case, however, since the EB item is a “Tick all that apply” question, the harmonisation was implemented already during data import and variable construction. Therefore, no additional recoding is performed at the crosswalk table stage for this item. The crosswalk structure is still retained for consistency with the overall harmonisation workflow applied to other items, even though its added value is limited here.

Let’s look at the d_iu_acce items:

eb_cwt %>% filter(!(var_source == "isocntry")) %>% 
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
var_source var_label_source npos value_n value_label_source value_code survey target_var target_value
d_iu_acce_home At home 1 [0] 0: 11375 [0] 0 0 EB d_iu_acce_home 0
d_iu_acce_home At home 2 [1] 1: 4564 [1] 1 1 EB d_iu_acce_home 1
d_iu_acce_work At work 1 [0] 0: 13319 [0] 0 0 EB d_iu_acce_work 0
d_iu_acce_work At work 2 [1] 1: 2620 [1] 1 1 EB d_iu_acce_work 1
d_iu_acce_move On the move 1 [0] 0: 15647 [0] 0 0 EB d_iu_acce_move 0
d_iu_acce_move On the move 2 [1] 1: 292 [1] 1 1 EB d_iu_acce_move 1
d_iu_acce_othr Other place 1 [0] 0: 13782 [0] 0 0 EB d_iu_acce_othr 0
d_iu_acce_othr Other place 2 [1] 1: 2157 [1] 1 1 EB d_iu_acce_othr 1
d_iu_acce_na DK 1 [0] 0: 15786 [0] 0 0 EB d_iu_acce_na 0
d_iu_acce_na DK 2 [1] 1: 153 [1] 1 1 EB d_iu_acce_na 1

 

1.6. Recode survey data using the crosswalk table

To be able to merge survey data with the crosswalk table information, we first need to convert the wide data format to a long data format.

eb_small_long <- eb_small %>%
  mutate(across(everything(), as.character)) %>%
  pivot_longer(cols = c(starts_with("d_iu_acce"), isocntry), 
               names_to = "var_source", values_to = "value_source")

This is how the first six rows of the eb_small_long should look like:

v11 v308 v309 v310 v311 v312 v313 v314 v315 v316 v317 v318 v319 v476 caseid var_source value_source
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 d_iu_acce_home 0
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 d_iu_acce_work 0
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 d_iu_acce_move 0
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 d_iu_acce_othr 0
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 d_iu_acce_na 0
1.0472 0 0 0 0 0 0 0 0 0 0 1 0 10001 1 isocntry BE

Now we use left_join() to recode source values according to the crosswalk table, eb_cwt.

eb_hrmsd <- eb_small_long %>%
  left_join(eb_cwt, by = c("value_source" = "value_code", "var_source")) %>%
  select(-c(npos, value_n)) %>%
  mutate(target_value = as.character(target_value)) %>%
  pivot_wider(
    id_cols = c(v476, v11, v308:v319, survey, caseid),    # Columns to keep as unique identifiers
    names_from = target_var,      # Column that will become the new column names
    values_from = target_value         # Column containing the values for those new columns
  ) %>% pivot_longer(
    cols = starts_with("d_iu_acce"),
    names_to = "target_var", values_to = "target_value") %>%
  rename(caseID_source = v476)

Now, EB 2001 data is ready for harmonisation. This is how the first six rows of the eb_hrmsd should look like:

caseID_source v11 v308 v309 v310 v311 v312 v313 v314 v315 v316 v317 v318 v319 survey caseid country_source target_var target_value
10001 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 EB 1 BE d_iu_acce_home 0
10001 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 EB 1 BE d_iu_acce_work 0
10001 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 EB 1 BE d_iu_acce_move 0
10001 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 EB 1 BE d_iu_acce_othr 0
10001 1.0472 0 0 0 0 0 0 0 0 0 0 1 0 EB 1 BE d_iu_acce_na 0
10002 1.022 0 0 0 0 0 0 0 0 0 0 1 0 EB 2 BE d_iu_acce_home 0
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use. This data includes both the source variables and target variables. Users might benefit from the inclusion of both source and target variables.

saveRDS(eb_hrmsd, paste("data/",  target_var_hrms, "_eb.rds", sep = ''))

 

2. Prepare Data: ESS 2020

We will follow the same steps used for the EB 2001 item.

 

2.1. Import data

ess <- haven::read_sav("data/ESS10.sav", user_na=TRUE) 
Check the source item

Use the output to inspect individual source variables such as acchome. The same check can be applied to other variables, including accwrk, accmove, accoth, accnone, accref, accdk, and accna:

ess %>% count(acchome)
# A tibble: 2 × 2
  acchome            n
  <dbl+lbl>      <int>
1 0 [Not marked]  5677
2 1 [Marked]     31934
ess <-  ess %>% 
  mutate(d_iu_acce_na = ifelse(rowSums(across(c(accnone, accref, accdk, accna), ~.)) == 0, 
                               0, #0: not marked, 1: marked
                               1),
         d_iu_acce_na = labelled_spss(d_iu_acce_na, label = "d_iu_acce harmonised NA"))

The variable d_iu_acce_na is a harmonised indicator capturing whether any non-response or non-substantive categories are selected in the original ESS item. It is constructed from four source variables: accnone (“Location able to access the internet: None of the above”), accref (“Refusal”), accdk (“Don’t know”), and accna (“No answer”). The variable is coded as 0 = not marked when none of these categories is selected, and 1 = marked when at least one of them is selected. Please note that EB does not include a category equivalent to “None of the above.” For this reason, accnone is included in the d_iu_acce_na category.

 

2.2. Create codebook

Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. Note that there are two weight variables: design and post-stratification weights. Both of them are included.

codebook_ess <- create_codebook_short(ess) %>%
  mutate(survey = "ESS",
         target_var = ifelse(var_source == "cntry", "country_source", NA),
         target_var = ifelse(grepl("Design weight", var_label_source), "w1_design", target_var),
         target_var = ifelse(grepl("Post-stratification weight", var_label_source), "w2_poststr", target_var),
         target_var = ifelse(grepl("unified respondent number|Respondent's identification number|respondent ID", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(var_source == "acchome", "d_iu_acce_home", target_var),
         target_var = ifelse(var_source == "accwrk", "d_iu_acce_work", target_var),
         target_var = ifelse(var_source == "accmove", "d_iu_acce_move", target_var),
         target_var = ifelse(var_source == "accoth", "d_iu_acce_othr", target_var),
         target_var = ifelse(var_source == "d_iu_acce_na", var_source, target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

The variable names which will be used in the harmonised data are listed under target_var.

var_source var_label_source survey target_var
idno Respondent's identification number ESS caseid_source
cntry Country ESS country_source
dweight Design weight ESS w1_design
pspwght Post-stratification weight including design weight ESS w2_poststr
acchome Location able to access the internet: Home ESS d_iu_acce_home
accwrk Location able to access the internet: Workplace ESS d_iu_acce_work
accmove Location able to access the internet: On the move ESS d_iu_acce_move
accoth Location able to access the internet: Some other place ESS d_iu_acce_othr
d_iu_acce_na d_iu_acce harmonised NA ESS d_iu_acce_na

 

2.3. Retrieve names of the chosen source variables

variables <- codebook_ess %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: idno, cntry, dweight, pspwght, acchome, accwrk, accmove, accoth, d_iu_acce_na.

 

2.4. Select a subset of the survey data containing only the chosen variables

ess_small <- ess %>% select(all_of(variables)) %>% mutate(caseid = row_number())

You will see that the following data set is a subset of the ESS 2020 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

idno cntry dweight pspwght acchome accwrk accmove accoth d_iu_acce_na caseid
10038 BE 0.8822203 0.9722756 1 0 1 1 0 1
10053 BE 1.0476425 0.8886350 1 0 0 1 0 2
10055 BE 1.0877413 0.7228110 1 0 0 1 0 3
10062 BE 0.9099100 1.0055653 0 1 0 0 0 4
10064 BE 0.9189489 0.6387054 1 1 1 1 0 5
10077 BE 0.9137402 0.7061659 1 1 1 0 0 6

 

2.5. Create a crosswalk table for the chosen variables

Similar to what is implemented in step 1.5, weight and ID variables are excluded from the crosswalk table. Only country and the substantive variable are used for creating the crosswalk table. Original codes for the country variable are preserved.

ess_cwt <- create_cwt(ess_small %>% select(cntry, starts_with("acc"), d_iu_acce_na)) %>%
  left_join(codebook_ess, by = join_by(var_source, var_label_source)) %>%
  mutate(target_value = NA,
         target_value = value_code,
         value_code = as.character(value_code)
  )

Although no recoding is done at this stage, the crosswalk table is still generated in order to maintain consistency with the established harmonisation workflow and to assign the target variable names.

Let’s look at the ess_cwt:

ess_cwt %>% filter(! var_source == "cntry") %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
var_source var_label_source npos value_n value_label_source value_code survey target_var target_value
acchome Location able to access the internet: Home 1 [0] Not marked: 5677 [0] Not marked 0 ESS d_iu_acce_home 0
acchome Location able to access the internet: Home 2 [1] Marked: 31934 [1] Marked 1 ESS d_iu_acce_home 1
accwrk Location able to access the internet: Workplace 1 [0] Not marked: 20717 [0] Not marked 0 ESS d_iu_acce_work 0
accwrk Location able to access the internet: Workplace 2 [1] Marked: 16894 [1] Marked 1 ESS d_iu_acce_work 1
accmove Location able to access the internet: On the move 1 [0] Not marked: 17078 [0] Not marked 0 ESS d_iu_acce_move 0
accmove Location able to access the internet: On the move 2 [1] Marked: 20533 [1] Marked 1 ESS d_iu_acce_move 1
accoth Location able to access the internet: Some other place 1 [0] Not marked: 19578 [0] Not marked 0 ESS d_iu_acce_othr 0
accoth Location able to access the internet: Some other place 2 [1] Marked: 18033 [1] Marked 1 ESS d_iu_acce_othr 1
d_iu_acce_na d_iu_acce harmonised NA 1 [0] 0: 32962 [0] 0 0 ESS d_iu_acce_na 0
d_iu_acce_na d_iu_acce harmonised NA 2 [1] 1: 4649 [1] 1 1 ESS d_iu_acce_na 1
Optional

It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.

write.xlsx(ess_cwt, paste("data/",  target_var_hrms, "_cwt_ess.xlsx", sep = ''))

 

2.6. Recode survey data using the crosswalk table

We first convert the wide data format to a long data format, and then merge survey data with the crosswalk table information.

ess_small_long <- ess_small %>%
  mutate(across(everything(), as.character)) %>%
  pivot_longer(cols = c(d_iu_acce_na, acchome, accwrk, accmove, accoth, cntry), 
               names_to = "var_source", values_to = "value_source")

This is how the first six rows of the ess_small_long should look like:

idno dweight pspwght caseid var_source value_source
10038 0.882220268249512 0.97227555513382 1 d_iu_acce_na 0
10038 0.882220268249512 0.97227555513382 1 acchome 1
10038 0.882220268249512 0.97227555513382 1 accwrk 0
10038 0.882220268249512 0.97227555513382 1 accmove 1
10038 0.882220268249512 0.97227555513382 1 accoth 1
10038 0.882220268249512 0.97227555513382 1 cntry BE

Now we use left_join() to recode source values according to the crosswalk table, ess_cwt.

ess_hrmsd <- ess_small_long %>%
  left_join(ess_cwt, by = c("value_source" = "value_code", "var_source")) %>% 
  select(-c(npos, value_n)) %>% 
  mutate(target_value = as.character(target_value)) %>% 
  pivot_wider(
    id_cols = c(dweight, pspwght, idno, caseid, survey),    # Columns to keep as unique identifiers
    names_from = target_var,      # Column that will become the new column names
    values_from = target_value         # Column containing the values for those new columns
  ) %>% pivot_longer(
    cols = starts_with("d_iu_acce"), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source = idno) 

ESS 2020 data is ready for harmonisation. This is how the first six rows of the ess_hrmsd should look like:

head(ess_hrmsd) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
dweight pspwght caseID_source caseid survey country_source target_var target_value
0.882220268249512 0.97227555513382 10038 1 ESS BE d_iu_acce_na 0
0.882220268249512 0.97227555513382 10038 1 ESS BE d_iu_acce_home 1
0.882220268249512 0.97227555513382 10038 1 ESS BE d_iu_acce_work 0
0.882220268249512 0.97227555513382 10038 1 ESS BE d_iu_acce_move 1
0.882220268249512 0.97227555513382 10038 1 ESS BE d_iu_acce_othr 1
1.04764246940613 0.888634979724884 10053 2 ESS BE d_iu_acce_na 0
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use.

saveRDS(ess_hrmsd, paste("data/",  target_var_hrms, "_ess.rds", sep = ''))

 

3. Harmonisation

With the following steps, we will create the harmonised Internet Access Locations data.

 

3.1. Standardise country names & apply labels

There are functions specifically written to standardise country names and apply labels. Please download the R file containing these functions here . Then save this file in the R project folder and import it into the R project via source("func_recoded_country.R").

How-to

If you cannot download the R-file, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the func_recoded_country-file into this new file. Make sure that you save this new file in your project folder under the name “func_recoded_country.R”.

source("func_recoded_country.R")
ess_1 <- ess_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")

eb_1 <- eb_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")
Check

You can run the following code to check the country variable:

table(eb_hrmsd$country_source, eb_1$country_new)

 

3.2. Weights

For details on decisions and procedures for including weight variables, please see the Make It Digital! data documentation page, section Weight Variables.

eb_fnl <- eb_1 %>% mutate(w1_design = v11,
                          w2_poststr = v11,
                          w3_combined = as.numeric(w2_poststr))

ess_fnl <- ess_1 %>% mutate(w1_design = dweight,
                            w2_poststr = pspwght,
                            w3_combined = as.numeric(w2_poststr))

 

3.3. Import additional information about the source data sets

This file, including additional information, can be downloaded here . Please save it into the “data” folder you generated previously.

add_data <- read_excel("data/from_doi_links_digital.xlsx") %>% 
  select(-studyno_source, -wave)

 

3.4. Combine all data

commons <- c("caseID_source", "caseid", "survey",
             "target_var","target_value","year", "country_new", "country_source_recoded",
             "w1_design", "w2_poststr", "w3_combined")

eb_fnl$year <- "2001"
ess_fnl$year <- "2020"


all_comb <- bind_rows(ess_fnl[, commons],
                       eb_fnl[, commons]) %>%
  left_join(add_data, by = c("target_var", "survey", "year")) %>%
  mutate(
    ## variables To Be Added
    studyno_I4NG = NA,
    version_I4NG = NA,
    doi_I4NG = NA,
    # caseID_I4NG = paste(survey, year, country_new, caseID_source, sep = ''),
    caseID_I4NG = paste(survey, year, country_new, caseid, sep = ''),
    #country_year
    country_year = paste(country_new, year, sep = '_'),
    # caseID = NA,
    caseID = row_number(),
    # code the lengths of response scales in each project
    npoints = NA) %>%
  rename(caseid_sw = caseid)  # Rename to avoid SPSS duplicate name error
Check

Let’s check the data set:

head(all_comb) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
caseID_source caseid_sw survey target_var target_value year country_new country_source_recoded w1_design w2_poststr w3_combined title_source doi_source studyno_I4NG version_I4NG doi_I4NG caseID_I4NG country_year caseID npoints
10038 1 ESS d_iu_acce_na 0 2020 BE BE 0.882220268249512 0.97227555513382 0.9722756 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE1 BE_2020 1 NA
10038 1 ESS d_iu_acce_home 1 2020 BE BE 0.882220268249512 0.97227555513382 0.9722756 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE1 BE_2020 2 NA
10038 1 ESS d_iu_acce_work 0 2020 BE BE 0.882220268249512 0.97227555513382 0.9722756 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE1 BE_2020 3 NA
10038 1 ESS d_iu_acce_move 1 2020 BE BE 0.882220268249512 0.97227555513382 0.9722756 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE1 BE_2020 4 NA
10038 1 ESS d_iu_acce_othr 1 2020 BE BE 0.882220268249512 0.97227555513382 0.9722756 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE1 BE_2020 5 NA
10053 2 ESS d_iu_acce_na 0 2020 BE BE 1.04764246940613 0.888634979724884 0.8886350 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE2 BE_2020 6 NA
distinct(all_comb, target_var, survey, year)
# A tibble: 10 × 3
   target_var     survey year 
   <chr>          <chr>  <chr>
 1 d_iu_acce_na   ESS    2020 
 2 d_iu_acce_home ESS    2020 
 3 d_iu_acce_work ESS    2020 
 4 d_iu_acce_move ESS    2020 
 5 d_iu_acce_othr ESS    2020 
 6 d_iu_acce_home EB     2001 
 7 d_iu_acce_work EB     2001 
 8 d_iu_acce_move EB     2001 
 9 d_iu_acce_othr EB     2001 
10 d_iu_acce_na   EB     2001 

 

3.5. Apply transformation

Since the items are “Tick all that apply” questions, we implemented the recoding in steps 1.1 and 2.1 Therefore, in this step we do not perform any additional transformations or recoding. The procedure is limited to organising the variables and reshaping the data from long to wide format.

all_hrmsd <- all_comb %>% 
  mutate(value_hrmsd = as.numeric(target_value)) %>%
  rename(var_hrmsd = target_var) %>%
  select(-var_hrmsd, -value_hrmsd, var_hrmsd, value_hrmsd, -caseID, caseID, -ends_with("_source"), ends_with("_source"), -target_value, -npoints) %>% rename(country_I4NG = country_new)%>%
  pivot_wider(
    id_cols = c(doi_source, title_source, caseID_source, caseid_sw, survey, country_I4NG, country_source_recoded, year, country_year, w1_design, w2_poststr, w3_combined, caseID_I4NG),    
    names_from = var_hrmsd,      # Column that will become the new column names
    values_from = value_hrmsd # Column containing the values for those new columns
    )

Now the harmonised Internet Access Locations data are ready. This is how the first six rows of the all_hrmsd should look like:

doi_source title_source caseID_source caseid_sw survey country_I4NG country_source_recoded year country_year w1_design w2_poststr w3_combined caseID_I4NG d_iu_acce_na d_iu_acce_home d_iu_acce_work d_iu_acce_move d_iu_acce_othr
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10038 1 ESS BE BE 2020 BE_2020 0.882220268249512 0.97227555513382 0.9722756 ESS2020BE1 0 1 0 1 1
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10053 2 ESS BE BE 2020 BE_2020 1.04764246940613 0.888634979724884 0.8886350 ESS2020BE2 0 1 0 0 1
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10055 3 ESS BE BE 2020 BE_2020 1.08774125576019 0.722811043262482 0.7228110 ESS2020BE3 0 1 0 0 1
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10062 4 ESS BE BE 2020 BE_2020 0.909909963607788 1.00556528568268 1.0055653 ESS2020BE4 0 0 1 0 0
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10064 5 ESS BE BE 2020 BE_2020 0.918948888778687 0.638705432415009 0.6387054 ESS2020BE5 0 1 1 1 1
https://doi.org/10.21338/ess10e03_2 Democracy, Digital social contacts 10077 6 ESS BE BE 2020 BE_2020 0.913740217685699 0.706165909767151 0.7061659 ESS2020BE6 0 1 1 1 0

 

3.6. Export data

#Rdata
saveRDS(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.rds", sep = ''))

#SPSS file
write_sav(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.sav", sep = ''))

#STATA file
write_dta(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.dta", sep = ''))

#CSV file
write.csv(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.csv", sep = ''), row.names = F, quote = T)

 

Summary

Internet Access Locations was administered in EB 2001 and ESS 2020. Our script, first, prepares these two data sets for harmonisation so that they are consistent in format via codebooks and crosswalk tables. After this step, the item is ready for subsequent analysis!

To go back to the Make it Digital! Toolbox page, please click here!

Back to top

References

Kołczyńska, M. (2022). Combining multiple survey sources: A reproducible workflow and toolbox for survey data harmonization. Methodological Innovations, 15(1), 62–72. https://doi.org/10.1177/20597991221077923
R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
RStudio Team. (2023). RStudio: Integrated development environment for R. https://www.rstudio.com/

© EU Funded Project 101131118 — Infra4NextGen

 

Subject to Terms of Use | Privacy notice | Cookie policy | Built with R and Quarto