Conversation
…r_triangle function
…nces where the group_by variable(s) are different for the synthetic and actual data
awunderground
left a comment
There was a problem hiding this comment.
- What happens if a group exists in one data set but not the other data set?
- I like how you restructured the output of
util_corr(), but it broke ALL of the tests. We need to rewrite the tests to reference the new output structure.
|
|
||
| # reorder data names | ||
| # reorder data names (this appears to check if the variables are the same) | ||
| # issue when the groups in the synthetic data do not match the groups in the og data, and vice versa |
There was a problem hiding this comment.
"og data" may be a little casual for our roxygen headers...
| dplyr::group_split(dplyr::across({{ group_by }})) | ||
|
|
||
| groups <- lapply(data, function(x) dplyr::select(x, {{ group_by }}) |> | ||
| slice(1)) |
There was a problem hiding this comment.
dplyr::slice() instead of just slice().
There was a problem hiding this comment.
Can you replace this with count(data, groups)?
There was a problem hiding this comment.
This code is to add the group by variables to the final datasets. I can add additional code to add the Ns to the metric data. I need to think more about how to add it to the corr_data dataset.
There was a problem hiding this comment.
count(data, {{ group_by }}) will return a data frame with the groups and the frequency of the groups that you can plug into bind_cols() below.
| return(list( | ||
| corr_data, | ||
| metrics | ||
| )) |
There was a problem hiding this comment.
return(
list(
corr_data,
metrics
)
)| # thinking about filling in all of groupings for each dataset first then running everything else | ||
| data <- dplyr::select(data, names(synthetic_data)) | ||
|
|
||
| synthetic_data <- dplyr::select(synthetic_data, dplyr::where(is.numeric), {{ group_by }}) |> |
There was a problem hiding this comment.
We're still using %>% instead of |> now to make sure the code is backwards compatible with R < 4.0.0.
| difference = .data$original - .data$synthetic, | ||
| proportion_difference = .data$difference / .data$original) | ||
|
|
||
| correlation_data <- bind_cols(correlation_data, groups) |
| correlation_fit = map_dbl(results, "correlation_fit"), | ||
| correlation_difference_mae = map_dbl(results, "correlation_difference_mae"), | ||
| correlation_difference_rmse = map_dbl(results, "correlation_difference_rmse"), |
| correlation_fit = map_dbl(results, "correlation_fit"), | ||
| correlation_difference_mae = map_dbl(results, "correlation_difference_mae"), | ||
| correlation_difference_rmse = map_dbl(results, "correlation_difference_rmse"), | ||
| bind_rows(groups) |
| bind_rows(groups) | ||
| ) | ||
|
|
||
| corr_data <- dplyr::bind_rows(map_dfr(results, "correlation_data")) |
No description provided.