From e4198f2868f3adbdd0508bd955705031545addd8 Mon Sep 17 00:00:00 2001
From: gdutz <30431062+gdutz@users.noreply.github.com>
Date: Tue, 24 Aug 2021 11:20:05 +0200
Subject: [PATCH] Change first argument of leo_svydesign() to "data"

---
 DESCRIPTION       |  2 +-
 R/leo_svydesign.R | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 9202bde..0131ecb 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: leo
 Type: Package
 Title: Useful functions for LEO surveys
-Version: 0.2.5
+Version: 0.2.6
 Author: Gregor Dutz
 Maintainer: Gregor Dutz <gregor.dutz@uni-hamburg.de>
 Description: Implements simple functions to handle data from two German surveys 
diff --git a/R/leo_svydesign.R b/R/leo_svydesign.R
index 08464a6..1079d0a 100644
--- a/R/leo_svydesign.R
+++ b/R/leo_svydesign.R
@@ -1,40 +1,40 @@
 #' Creates survey design objects for LEO 2010 and 2018.
 #'
-#' @param df Survey data
+#' @param data Survey data
 #' @param survey Choose between leo2010 and leo2018 (leo2018hoch implements weighting based on population totals).
 #' @param replist When true, the function returns an imputation list instead of survey design object.
 #' @return A survey design or imputation list object.
 #'
 #' @importFrom rlang .data
 #' @export
-leo_svydesign <- function(df, survey = "leo2018", replist = FALSE) {
-  names(df) <- tolower(names(df))
+leo_svydesign <- function(data, survey = "leo2018", replist = FALSE) {
+  names(data) <- tolower(names(data))
 
   # create survey design object for LEO 2010 or LEO 2018 ----
   if (survey == "leo2010" || survey == "leo2018" || survey == "leo2018hoch") {
     if (survey == "leo2010") {
       # remove logits
-      df <- df |> dplyr::select(-tidyselect::matches("^pv[1-5]$"))
+      data <- data |> dplyr::select(-tidyselect::matches("^pv[1-5]$"))
       # rename variables for pvs and levels
       old=c("pv1_62", "pv2_62", "pv3_62", "pv4_62", "pv5_62",
             "pv1_alphalevel_62", "pv2_alphalevel_62", "pv3_alphalevel_62", "pv4_alphalevel_62", "pv5_alphalevel_62")
       new=c("pv1", "pv2", "pv3", "pv4", "pv5",
             "alpha_pv1", "alpha_pv2", "alpha_pv3", "alpha_pv4", "alpha_pv5")
-      df <- df |> dplyr::rename_at(dplyr::vars(old), ~new)
+      data <- data |> dplyr::rename_at(dplyr::vars(old), ~new)
     }
 
     # some functions need a helper variable
-    df$a <- as.numeric(1)
+    data$a <- as.numeric(1)
 
     # get column names of pvs and levels
-    lit <- grep("^pv[0-9]+", colnames(df), value = TRUE)
-    alp <- grep("^alpha_pv[0-9]+", colnames(df), value = TRUE)
+    lit <- grep("^pv[0-9]+", colnames(data), value = TRUE)
+    alp <- grep("^alpha_pv[0-9]+", colnames(data), value = TRUE)
     # column names of all other variables
-    all <- df |> dplyr::select(-tidyselect::one_of(lit), -tidyselect::one_of(alp))
+    all <- data |> dplyr::select(-tidyselect::one_of(lit), -tidyselect::one_of(alp))
     all <- colnames(all)
     # create list with one pv-variable and one level-variable each (and all other variables)
     repList <- lit |>
-      purrr::map(function(x) {dplyr::select(df, all, paste0("alpha_", x), x) |>
+      purrr::map(function(x) {dplyr::select(data, all, paste0("alpha_", x), x) |>
           dplyr::rename(pv = !!x) |>
           dplyr::rename(alpha_pv = !!paste0("alpha_", x))})
 
-- 
GitLab