label_extracter
label_extracter.RdA function to extract specific columns from the DMOGG dataset based on provided labels. The user can choose to extract all columns, select specific columns, or choose from predefined groups of columns. Additionally, the user can opt to include info about the labels presence in different datasets to the return dataset.
Usage
label_extracter(
label,
columns = "all",
column_list,
choice,
presence = FALSE,
dataset = "DMOGG",
email = Sys.getenv("email")
)Arguments
- label
A vector of labels to filter the dataset on. These should be in the form of ANBjjjjlabeltype######.
- columns
A character string specifying which columns to extract. Options are "all" (default), "select", "list", or "group".
all: extracts all columns from the dataset.select: allows the user to interactively select columns from the dataset.list: extracts columns specified in thecolumn_listargument.group: allows the user to choose from predefined groups of columns (e.g., "comp", "georef", "okl", "gewicht", "geslacht", "leeftijd_cat", "toek", "coord").
- column_list
A vector of column names to extract when
columnsis set to "list". This argument is ignored for other values ofcolumns.- choice
A character string specifying the group of columns to extract when
columnsis set to "group". Options include "comp", "georef", "okl", "gewicht", "geslacht", "leeftijd_cat", "toek", and "coord". This argument is ignored for other values ofcolumns.- presence
A boolean indicating whether to include information about the presence of the labels in the "DMOGG" dataset. Default is FALSE.
- dataset
A character string specifying the dataset to extract from. Currently, only "DMOGG" is supported. Default is "DMOGG".
een character met het email adres van de gebruiker. Wordt gebruikt voor authenticatie bij het updaten van de google drive bestanden. Standaard wordt het email adres uit de system variables gehaald, indien deze niet bestaat zal er een popup verschijnen waarin je je email adres kan ingeven.
Value
A data frame containing the extracted columns for the specified labels, with an additional column indicating the dataset. If presence is set to TRUE, it also includes information about the presence of the labels in different datasets.
Details
The function checks the validity of the input parameters and reads the specified dataset. It then filters the dataset based on the provided labels and extracts the specified columns.
If presence is set to TRUE, it also joins information about the presence of the labels in the "DMOGG" dataset. Presence data is retrieved using the label_selecter function, which may have access restrictions. If you encounter issues with retrieving presence data, try setting presence to FALSE. If presence is set to FALSE only labels present in the "DMOGG" dataset are returned. If presence is set to TRUE all labels are returned, labels not present in DMOGG get FALSE in the DMOG_GEO column.
Finally, it adds a column indicating the dataset and returns the extracted data.
When using the "select" option for columns, the user will be prompted to choose which columns to extract from the dataset. When using the "group" option, the user can choose from predefined groups of columns that are relevant for different types of analyses.
Examples
if (FALSE) { # \dontrun{
# Example 1: Extract all columns for specific labels
data_all <- label_extracter(label = c("ANB2024REEGEIT004002",
"ANB2024REEGEIT004001"),
columns = "all")
# Example 2: Interactively select columns to extract for specific labels
data_select <- label_extracter(label = c("ANB2024REEGEIT004002",
"ANB2024REEGEIT004001"),
columns = "select")
# Example 3: Extract specific columns from a list for specific labels
data_list <- label_extracter(label = c("ANB2024REEGEIT004002",
"ANB2024REEGEIT004001"),
columns = "list",
column_list = c("label_nummer_samen", "onderkaaklengte_comp",
"geslacht_comp"))
# Example 4: Extract a predefined group of columns for specific labels
data_group <- label_extracter(label = c("ANB2024REEGEIT004002",
"ANB2024REEGEIT004001"),
columns = "group",
choice = "comp")
} # }