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: ISSP 2015
  • 2. Prepare Data: ESS 2020
  • 3. Harmonisation
  • Summary

Frequency of Doing Home-Office

This page guides you through the harmonisation process of the Frequency of Doing Home-Office item.

The item was administered in ESS 2020 and ISSP 2015. 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 Frequency of Doing Home-Office. 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 ISSP 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", "openxlsx", "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 cannot 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_wj_hoff”. The name is a combination of “d” representing the main topic “digital”, the concept “work and job” and the variable label “home-office”.

target_var_hrms <- "d_wj_hoff"

Before we can harmonise any data, we need to prepare the source data sets:

1. Prepare Data: ISSP 2015

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

1.1 Import data

issp <- haven::read_sav("data/ZA6770_v2-1-0.sav", user_na=TRUE)
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

issp %>% count(v32)
# A tibble: 8 × 2
  v32                                                              n
  <dbl+lbl>                                                    <int>
1 0 (NA) [Not applicable (c.2 in v20 or 2,3 in WORK);NAV (DK)] 23618
2 1 [Always]                                                    1827
3 2 [Often]                                                     2553
4 3 [Sometimes]                                                 4266
5 4 [Hardly ever]                                               3762
6 5 [Never]                                                    14815
7 8 (NA) [Can't choose]                                          237
8 9 (NA) [No answer, refused]                                    590

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_issp <- create_codebook_short(issp) %>%
 mutate(survey = "ISSP",
       target_var = ifelse(var_source == "c_alphan", "country_source", NA),
       target_var = ifelse(var_source == "WEIGHT", "w2_poststr", target_var),
       target_var = ifelse(grepl("RESPONDENT ID|ID Number", var_label_source), "caseID_source", target_var),
       target_var = ifelse(grepl("work at home during working hours", var_label_source),
                           target_var_hrms,
                           target_var),
       target_var = gsub(" ", "_", target_var),
       target_var = tolower(target_var))

codebook_issp includes the columns called: var_source, var_label_source, survey, 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
c_alphan Country Prefix ISO 3166 ISSP country_source
v32 Q14a And how often applies: work at home during working hours ISSP d_wj_hoff
CASEID ID Number of Respondent ISSP caseid_source
WEIGHT Weighting factor ISSP w2_poststr

 

1.3. Retrieve names of the chosen source variables

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

The retrieved variables are: c_alphan, v32, CASEID, WEIGHT.

 

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

issp_small <- issp %>% select(all_of(variables)) %>% mutate(caseid = row_number())

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

c_alphan v32 CASEID WEIGHT caseid
AT 5 2015000400001034 0.91638 1
AT 3 2015000400001035 0.92712 2
AT 3 2015000400001036 1.00808 3
AT 5 2015000400001037 0.78642 4
AT 3 2015000400001038 0.89883 5
AT 5 2015000400001039 0.84706 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. Lastly, NAs are assigned to missing values.

issp_cwt <- create_cwt(issp_small %>% select(c_alphan, v32)) %>% 
  left_join(codebook_issp, by = join_by(var_source, var_label_source)) %>% 
  mutate(target_value = NA,
         target_value = ifelse(!grepl("No answer|Can't choose", value_label_source),
                               value_code,
                               target_value),
         value_code = as.character(value_code)
  )
Important

There are decisions about the substantive variable made by taking into account both ESS and ISSP data. 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:

  • Definitions of missing values differ across ESS and ISSP. Missing values are not harmonised; instead, they are recoded into a single missing category, “NA”, with the exception of “Not applicable.” In the original ISSP 2015 data, respondents who were filtered out before this question was administered were coded as “0 Not applicable (c.2 in v20 or 2,3 in WORK); NAV (DK)”. These cases were not recoded to “NA”; instead, in the harmonised dataset they were assigned the code -999 to indicate “(Inap. from source data sets)” in section 3.5. Apply transformation.

Let’s look at the correspondence between d_wj_hoff and wrkhome:

issp_cwt %>% filter(var_source == "v32") %>% 
 
  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
v32 Q14a And how often applies: work at home during working hours 1 [0] Not applicable (c.2 in v20 or 2,3 in WORK);NAV (DK): 23618 [0] Not applicable (c.2 in v20 or 2,3 in WORK);NAV (DK) 0 ISSP d_wj_hoff 0
v32 Q14a And how often applies: work at home during working hours 2 [1] Always: 1827 [1] Always 1 ISSP d_wj_hoff 1
v32 Q14a And how often applies: work at home during working hours 3 [2] Often: 2553 [2] Often 2 ISSP d_wj_hoff 2
v32 Q14a And how often applies: work at home during working hours 4 [3] Sometimes: 4266 [3] Sometimes 3 ISSP d_wj_hoff 3
v32 Q14a And how often applies: work at home during working hours 5 [4] Hardly ever: 3762 [4] Hardly ever 4 ISSP d_wj_hoff 4
v32 Q14a And how often applies: work at home during working hours 6 [5] Never: 14815 [5] Never 5 ISSP d_wj_hoff 5
v32 Q14a And how often applies: work at home during working hours 7 [8] Can't choose: 237 [8] Can't choose 8 ISSP d_wj_hoff NA
v32 Q14a And how often applies: work at home during working hours 8 [9] No answer, refused: 590 [9] No answer, refused 9 ISSP d_wj_hoff NA
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(eb_cwt, paste("data/",  target_var_hrms, "_cwt_issp.xlsx", sep = ''))

 

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.

issp_small_long <- issp_small %>% 
  mutate(across(everything(), as.character)) %>% 
  pivot_longer(cols = c(v32, c_alphan),
               names_to = "var_source", values_to = "value_source") 

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

CASEID WEIGHT caseid var_source value_source
2015000400001034 0.91638 1 v32 5
2015000400001034 0.91638 1 c_alphan AT
2015000400001035 0.92712 2 v32 3
2015000400001035 0.92712 2 c_alphan AT
2015000400001036 1.00808 3 v32 3
2015000400001036 1.00808 3 c_alphan AT

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

issp_hrmsd <- issp_small_long %>%
  left_join(issp_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(CASEID, WEIGHT, caseid, survey),    
    names_from = target_var,      
    values_from = target_value       
  ) %>% pivot_longer(
    cols = all_of(target_var_hrms), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source =  CASEID)

Now, ISSP data is ready for harmonisation. This is how the first six rows of the issp_hrmsd should look like:

caseID_source WEIGHT caseid survey country_source target_var target_value
2015000400001034 0.91638 1 ISSP AT d_wj_hoff 5
2015000400001035 0.92712 2 ISSP AT d_wj_hoff 3
2015000400001036 1.00808 3 ISSP AT d_wj_hoff 3
2015000400001037 0.78642 4 ISSP AT d_wj_hoff 5
2015000400001038 0.89883 5 ISSP AT d_wj_hoff 3
2015000400001039 0.84706 6 ISSP AT d_wj_hoff 5
Optional

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

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 ISSP 2015 item. As expected, ESS and ISSP data have differences, and they are taken into account in implementing these steps.

  2.1. Import data

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

Use this output to compare it with your output. Check especially if the labels match.

ess %>% count(wrkhome)
# A tibble: 10 × 2
   wrkhome                        n
   <dbl+lbl>                  <int>
 1  1 [Every day]              1945
 2  2 [Several times a week]   2328
 3  3 [Several times a month]  1785
 4  4 [Once a month]            582
 5  5 [Less often]             1712
 6  6 [Never]                 12186
 7 66 (NA) [Not applicable]   16710
 8 77 (NA) [Refusal]            155
 9 88 (NA) [Don't know]         134
10 99 (NA) [No answer]           74

 

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("RESPONDENT ID|identi", var_label_source), "caseID_source", target_var),
         target_var = ifelse(grepl("^Work from home or place of choice, how often$", var_label_source), 
                             target_var_hrms, 
                             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
wrkhome Work from home or place of choice, how often ESS d_wj_hoff

 

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, wrkhome.

 

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 including the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

idno cntry dweight pspwght wrkhome caseid
10038 BE 0.8822203 0.9722756 66 1
10053 BE 1.0476425 0.8886350 66 2
10055 BE 1.0877413 0.7228110 66 3
10062 BE 0.9099100 1.0055653 6 4
10064 BE 0.9189489 0.6387054 6 5
10077 BE 0.9137402 0.7061659 6 6

 

2.5. Create a crosswalk table for the chosen variables

Similar to what was 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. For the substantive variable, “NA” is assigned to missing values; the other values are kept identical.

ess_cwt <- create_cwt(ess_small %>% select(wrkhome, cntry)) %>%
  left_join(codebook_ess, by = join_by(var_source, var_label_source)) %>%
  mutate(target_value = NA,
         target_value = ifelse(!grepl("know|efusal|answer|NA|Can't choose|]DK|] DK|Na", value_label_source),
                               value_code, 
                               target_value),
         value_code = as.character(value_code)
  )
Important

Similarly, missing values are not harmonised; instead, they are recoded into a single missing category, “NA”, except for “Not applicable.” In ESS 2020, the category “66 Not applicable” is retained because it represents respondents who do not work. These cases were not recoded to “NA”; instead, in the harmonised dataset they were assigned the code -999 to indicate “(Inap. from source data sets)” in section 3.5. Apply transformation.

Let’s look at the correspondence between d_wj_hoff and wrkhome:

ess_cwt %>% filter(var_source == "wrkhome") %>%
  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
wrkhome Work from home or place of choice, how often 1 [1] Every day: 1945 [1] Every day 1 ESS d_wj_hoff 1
wrkhome Work from home or place of choice, how often 2 [2] Several times a week: 2328 [2] Several times a week 2 ESS d_wj_hoff 2
wrkhome Work from home or place of choice, how often 3 [3] Several times a month: 1785 [3] Several times a month 3 ESS d_wj_hoff 3
wrkhome Work from home or place of choice, how often 4 [4] Once a month: 582 [4] Once a month 4 ESS d_wj_hoff 4
wrkhome Work from home or place of choice, how often 5 [5] Less often: 1712 [5] Less often 5 ESS d_wj_hoff 5
wrkhome Work from home or place of choice, how often 6 [6] Never: 12186 [6] Never 6 ESS d_wj_hoff 6
wrkhome Work from home or place of choice, how often 7 [66] Not applicable: 16710 [66] Not applicable 66 ESS d_wj_hoff 66
wrkhome Work from home or place of choice, how often 8 [77] Refusal: 155 [77] Refusal 77 ESS d_wj_hoff NA
wrkhome Work from home or place of choice, how often 9 [88] Don't know: 134 [88] Don't know 88 ESS d_wj_hoff NA
wrkhome Work from home or place of choice, how often 10 [99] No answer: 74 [99] No answer 99 ESS d_wj_hoff NA
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(wrkhome, 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 wrkhome 66
10038 0.882220268249512 0.97227555513382 1 cntry BE
10053 1.04764246940613 0.888634979724884 2 wrkhome 66
10053 1.04764246940613 0.888634979724884 2 cntry BE
10055 1.08774125576019 0.722811043262482 3 wrkhome 66
10055 1.08774125576019 0.722811043262482 3 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(idno, dweight, pspwght, 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 = all_of(target_var_hrms), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source = idno)

ESS 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"))
caseID_source dweight pspwght caseid survey country_source target_var target_value
10038 0.882220268249512 0.97227555513382 1 ESS BE d_wj_hoff 66
10053 1.04764246940613 0.888634979724884 2 ESS BE d_wj_hoff 66
10055 1.08774125576019 0.722811043262482 3 ESS BE d_wj_hoff 66
10062 0.909909963607788 1.00556528568268 4 ESS BE d_wj_hoff 6
10064 0.918948888778687 0.638705432415009 5 ESS BE d_wj_hoff 6
10077 0.913740217685699 0.706165909767151 6 ESS BE d_wj_hoff 6
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 Frequency of Doing Home-Office 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")

issp_1 <- issp_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")


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")
Check

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

table(issp_1$country_source, issp_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.

issp_fnl <- issp_1 %>% mutate(w1_design = WEIGHT,
                            w2_poststr = WEIGHT, 
                            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")

ess_fnl$year <-"2020"
issp_fnl$year <-"2015"

all_comb <- bind_rows(ess_fnl[, commons],
                      issp_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 = case_when( survey == "ESS" ~ 6, survey == "ISSP" ~ 5, TRUE ~ 999 )
    ) %>%
 rename(caseid_sw = caseid, country_I4NG = country_new) 
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_I4NG 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_wj_hoff 66 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 6
10053 2 ESS d_wj_hoff 66 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 2 6
10055 3 ESS d_wj_hoff 66 2020 BE BE 1.08774125576019 0.722811043262482 0.7228110 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE3 BE_2020 3 6
10062 4 ESS d_wj_hoff 6 2020 BE BE 0.909909963607788 1.00556528568268 1.0055653 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE4 BE_2020 4 6
10064 5 ESS d_wj_hoff 6 2020 BE BE 0.918948888778687 0.638705432415009 0.6387054 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE5 BE_2020 5 6
10077 6 ESS d_wj_hoff 6 2020 BE BE 0.913740217685699 0.706165909767151 0.7061659 Democracy, Digital social contacts https://doi.org/10.21338/ess10e03_2 NA NA NA ESS2020BE6 BE_2020 6 6
distinct(all_comb, target_var, survey, year)
# A tibble: 2 × 3
  target_var survey year 
  <chr>      <chr>  <chr>
1 d_wj_hoff  ESS    2020 
2 d_wj_hoff  ISSP   2015 

 

3.5. Apply transformation

Response categories of the harmonised variable are (01) = Always, (02) = Often, (03) = Sometimes, (04) = Hardly ever, and (05) = Never. The ESS categories were recoded as follows: (01) Every day → 1, (02) Several times a week → 2, (03) Several times a month → 3, (04) Once a month → 3, (05) Less often → 4, and (06) Never → 5. Cases coded as “Not applicable” in ESS and respondents filtered out in ISSP 2015 were assigned -999 (Inap. from source data sets) in the harmonised dataset.

all_hrmsd <- all_comb %>%
  # apply transformation
  mutate(value_hrmsd = case_when(survey == "ESS" & target_value == 3 ~ 3, # 1 and 2 remained the same
                                 survey == "ESS" & target_value == 4 ~ 3,
                                 survey == "ESS" & target_value == 5 ~ 4,
                                 survey == "ESS" & target_value == 6 ~ 5,
                                 survey == "ESS" & target_value == 66 ~ -999,
                                 survey == "ISSP" & target_value == 0 ~ -999,
                                 TRUE ~ as.numeric(target_value))) %>%
  # style and format
  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)%>% 
  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 Climate Change Worries 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_wj_hoff
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 -999
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 -999
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 -999
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 5
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 5
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 5

 

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

Frequency of Doing Home-Office was administered in ISSP 2015 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. Then, the response categories are harmonised using the identity linking/linear stretch approach. 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