Remove the situation column from `summary` when all_situations=FALSE

Open
#6 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by locating the summary implementation and checking how all_situations=FALSE shapes its output. Compare the current and proposed outputs, including the suggestion about removing group, and check existing tests for summary behavior. Done means the returned data frame omits the requested redundant columns without changing the remaining statistics.

Written by the indexing model from the issue text.

Description

enhancement

When using all_situations=FALSE (the default) in summary, we still get the "situation" column, which is just polluting the output data.frame because all values are set to "all_situations" anyway.

Example:

library(CroPlotR)
workspace <- system.file(
    file.path("extdata", "stics_example_1"),
    package = "CroPlotR"
)

sim <- SticsRFiles::get_sim(
    workspace = workspace,
    usms_file = file.path(workspace, "usms.xml")
)

obs <- SticsRFiles::get_obs(
    workspace = workspace,
    usm = situations,
    usms_file = file.path(workspace, "usms.xml")
)

summary(sim,obs = obs, stats = c("EF", "RMSE"))

Returns:

# A tibble: 2 × 5
  group     situation      variable    EF  RMSE
  <chr>     <chr>          <chr>    <dbl> <dbl>
1 Version_1 all_situations lai_n    0.636 0.631
2 Version_1 all_situations masec_n  0.871 0.945

I propose to remove the "situation" column in this case to get:

# A tibble: 2 × 5
  group    variable    EF  RMSE
  <chr>    <chr>    <dbl> <dbl>
1 Version_1 lai_n    0.636 0.631
2 Version_1 masec_n  0.871 0.945

And in this case we should we also remove the "group" variable.

What we could do is:

if (length(unique(df$variable)) == 1){
select(df, -variable)
}

if (length(unique(df$group)) == 1){
select(df, -group)
}
Dominant language
R
Stars
1
Forks
3
Avg merge
9h 41m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SticsRPacks/CroPlotR

All issues in SticsRPacks/CroPlotR

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.