Skip to content

Commit

Permalink
Update utils.R
Browse files Browse the repository at this point in the history
Moved step for updating elasticity with a custom elasticity.
  • Loading branch information
knoiva-indecon committed Jan 5, 2024
1 parent 175a101 commit 149e80b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions FrEDI/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,6 @@ extend_slrScalars <- function(
df_scalars, ### Main scalar values: df_mainScalars
elasticity = NULL
){
###### Elasticity ######
### Update exponent
if(!(elasticity |> is.null())){
# df_scalars <- df_scalars |> mutate(exp0 = (exp0 == 1) |> ifelse(exp0, elasticity))
#df_scalars <- df_scalars |> mutate(exp0 = (econScalarName=="vsl_usd") |> ifelse(elasticity, exp0))
df_scalars <- df_scalars |> mutate(exp0 = case_when(scalarName == "vsl_usd" ~ elasticity,
.default = NA))
} ### End if(!(elasticity |> is.null()))

###### By State ######
### By state
byState <- TRUE
Expand All @@ -369,6 +360,15 @@ extend_slrScalars <- function(
df0 <- df0 |> select(-all_of(drop1))
rm(drop0, drop1)

###### Elasticity ######
### Update exponent
if(!(elasticity |> is.null())){
# df_info <- df_info |> mutate(exp0 = (exp0 == 1) |> ifelse(exp0, elasticity))
df_info <- df_info |> mutate(exp0 = (econMultiplierName=="vsl_usd") |> ifelse(elasticity, exp0))
} ### End if(!(elasticity |> is.null()))
### Add column
df_info <- df_info |> mutate(econAdjName = "none")

###### Join Data & Scalar Info ######
### Join initial results & scalar info
drop0 <- c("byState")
Expand All @@ -390,7 +390,7 @@ extend_slrScalars <- function(
gather0 <- c("gdp_usd", "gdp_percap")
select0 <- gather0 |> c("year")
# select0 <- gather0 |> c("byState", "year")
df_mult0 <- df_se |> summarize_seScenario(national=T)
df_mult0 <- df_se |> summarize_seScenario(national=T)
df_mult0 <- df_mult0 |> filter(byState==0)
df_mult0 <- df_mult0 |> select(all_of(select0))
df_mult0 <- df_mult0 |> pivot_longer(
Expand Down

0 comments on commit 149e80b

Please sign in to comment.