You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there is no year, then we can ignore lines 3-4, and change line 5 to just contain "s_year1"
2. Our instat_calculation code
No changes
3. After our instat_calculation code
linked_data_name <- data_book$get_linked_to_data_name("data", link_cols=c("s_year1", "station"))
# Create the list dynamically using setNames
calculated_from_list <- c(
setNames("start_rain_status", linked_data_name),
setNames("start_rain", linked_data_name)
)
# Pass the dynamically created list into instat_calculation
start_rain_status_2 <- instat_calculation$new(
type = "calculation",
function_exp = "ifelse(!is.na(start_rain), TRUE, start_rain_status)",
calculated_from = calculated_from_list,
result_name = "start_rain_status",
save = 2
)
start_rain_combined_status_2 <- instat_calculation$new(type="combination", sub_calculations=list(start_rain_status_2))
data_book$run_instat_calculation(display=FALSE, param_list=list(drop=drop_val), calc=start_rain_combined_status_2)
data_book$convert_column_to_type(data_name="data", col_names="s_year1", to_type=year_type)
data_book$convert_column_to_type(data_name="data", col_names="station", to_type=station_type)
data_book$convert_linked_variable(from_data_frame="data", link_cols=c("s_year1", "station"))
data_book$remove_unused_station_year_combinations(data_name="data", year="s_year1", station="station")
rm(list=c("start_of_rains_combined", "grouping_by_station", "conditions_filter", "roll_sum_rain", "grouping_by_year", "doy_filter", "start_of_rains_doy", "start_rain_date", "start_of_rains_status", "year_type", "linked_data_name"))
If there is no station we:
i) do not run the remove_unused_station_year_combinations line,
ii) ignore convert_column_to_type for station_type
iii) we amend the linked_data_name to contain only s_year1:
# Create the list dynamically using setNames
calculated_from_list <- c(
setNames("start_rain_status", linked_data_name),
setNames("start_rain", linked_data_name)
)
# Pass the dynamically created list into instat_calculation
start_rain_status_2 <- instat_calculation$new(
type = "calculation",
function_exp = "ifelse(!is.na(start_rain), TRUE, start_rain_status)",
calculated_from = calculated_from_list,
result_name = "start_rain_status",
save = 2
)
start_rain_combined_status_2 <- instat_calculation$new(type="combination", sub_calculations=list(start_rain_status_2))
data_book$run_instat_calculation(display=FALSE, param_list=list(drop=drop_val), calc=start_rain_combined_status_2)
data_book$convert_column_to_type(data_name="data", col_names="s_year1", to_type=year_type)
data_book$convert_linked_variable(from_data_frame="data", link_cols=c("s_year1"))
The text was updated successfully, but these errors were encountered:
Now we've done the work to the end of rains dialog, there's a few bits we want to do to the start of rains dialog :)
I'll put this into three parts:
instat_calculation
codeinstat_calculation
codeinstat_calculation
code1. Before our
instat_calculation
code(We currently run lines 1-2 of this)
If there is no year, then we can ignore lines 3-4, and change line 5 to just contain "s_year1"
2. Our
instat_calculation
codeNo changes
3. After our
instat_calculation
codeIf there is no station we:
i) do not run the
remove_unused_station_year_combinations
line,ii) ignore
convert_column_to_type
forstation_type
iii) we amend the
linked_data_name
to contain onlys_year1
:The text was updated successfully, but these errors were encountered: