Skip to content

Commit

Permalink
Fixing error with if_else
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarrar Khan committed Nov 26, 2023
1 parent 56014bf commit df820f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/map.R
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ map <- function(data = NULL,
tbl_temp1<-tbl_temp1%>%
tidyr::gather(key=scenario,value=value,
-c(names(tbl_temp1)[!names(tbl_temp1) %in% paste(scenario_i,"_DiffAbs_",scenRef_i,sep="")]))%>%
dplyr::mutate(value = if_else(is.nan(value),0,value))
dplyr::mutate(value = dplyr::if_else(is.nan(value),0,value))

tbl_temp2 <-dataTblDiffb%>%
dplyr::mutate(!!paste(scenario_i,"_DiffPrcnt_",scenRef_i,sep=""):=((get(scenario_i)-get(scenRef_i))*100/get(scenRef_i)),
Expand All @@ -882,7 +882,7 @@ map <- function(data = NULL,
tbl_temp2<-tbl_temp2%>%
tidyr::gather(key=scenario,value=value,
-c(names(tbl_temp2)[!names(tbl_temp2) %in% paste(scenario_i,"_DiffPrcnt_",scenRef_i,sep="")]))%>%
dplyr::mutate(value = if_else(is.nan(value),0,value))
dplyr::mutate(value = dplyr::if_else(is.nan(value),0,value))

dataTblDiff<-dplyr::bind_rows(dataTblDiff,tbl_temp1,tbl_temp2)
}
Expand Down Expand Up @@ -1002,7 +1002,7 @@ map <- function(data = NULL,
tidyr::gather(key=scenario,value=value,
-c(names(tbl_temp1)[!names(tbl_temp1) %in% paste(scen_i,"_xDiffAbs_",xRef_i,sep="")]))%>%
dplyr::mutate(x=x_i)%>%
dplyr::mutate(value = if_else(is.nan(value),0,value))
dplyr::mutate(value = dplyr::if_else(is.nan(value),0,value))

tbl_temp2 <-dataTblDiffb%>%
dplyr::filter(scenario==scen_i)%>%
Expand All @@ -1013,7 +1013,7 @@ map <- function(data = NULL,
tidyr::gather(key=scenario,value=value,
-c(names(tbl_temp2)[!names(tbl_temp2) %in% paste(scen_i,"_xDiffPrcnt_",xRef_i,sep="")]))%>%
dplyr::mutate(x=x_i)%>%
dplyr::mutate(value = if_else(is.nan(value),0,value))
dplyr::mutate(value = dplyr::if_else(is.nan(value),0,value))

dataTblxDiff<-dplyr::bind_rows(dataTblxDiff,tbl_temp1,tbl_temp2)
}
Expand Down

0 comments on commit df820f6

Please sign in to comment.