Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Id creation #69

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ID_column_creation.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "Id_column_creation"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Id column creation

cchsflow dev currently contains updated variables and variable details. These both have the new rows needed for id creation allowing for the same function call



```{r}
library(cchsflow)
library(bllflow)


rec_data <- rec_with_table(cchs2001_p, variables = variables, variable_details = variable_details)

rec_data$id_year
```
9 changes: 8 additions & 1 deletion R/bll-flow-constructor-utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ bllflow_config_rec_data <- function(bllflow_object, config_env_name = NULL) {
base::get(data_name),
variables = bllflow_object$variables,
variable_details = bllflow_object$variable_details,
database_name = data_name)
database_name = data_name,
attach_data_name = TRUE, id_role_name = list(var_name = "row_ID", feeder_vars="ADM_RNO"))
assign(data_name, tmp_rec_data)
save(list = data_name,
file = file.path(config$data_dir,
Expand Down Expand Up @@ -121,6 +122,12 @@ bllflow_config_combine_data <- function(bllflow_object, config_env_name = NULL)
load(file.path(config$data_dir, paste0(data_name, "_recoded", ".RData")))
tmp_mod_data <- base::get(data_name)
tmp_mod_data[["data_name"]] <- data_name
# Create unique row id
if(config$unique_id){
id_cols <- select_vars_by_role("ID", bllflow_object$variables)

print("potato")
}
if (is.null(tmp_working_data)) {
tmp_working_data <- tmp_mod_data
} else {
Expand Down
6 changes: 2 additions & 4 deletions R/default_step_parsing.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,8 @@ create_recipe <-
variables) {
# Check variable roles for the recipe creation
# TODO bllflow support make this add to overall recipe
outcome_variable <-
as.character(variables[grepl("outcome,",
variables[[pkg.globals$argument.Role]]),
pkg.globals$argument.Variables])
outcome_variable <- select_vars_by_role("outcome", variables)

# TODO add a function for creating a proper formula
recipe_formula <- paste(outcome_variable, "~ .")

Expand Down
3 changes: 3 additions & 0 deletions R/label-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,11 @@ label_data <- function(label_list, data_to_label) {
as.numeric(levels(data_to_label[[variable_name]])
[data_to_label[[variable_name]]])
} else {
tmp <- as.numeric(data_to_label[[variable_name]])
if(sum(is.na(tmp))!= length(tmp)){
data_to_label[[variable_name]] <-
as.numeric(data_to_label[[variable_name]])
}
}
}
sjlabelled::set_label(data_to_label[[variable_name]]) <-
Expand Down
174 changes: 0 additions & 174 deletions R/module-instruction-parsing.R

This file was deleted.

Loading