Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More convenient col_decimals for summary.gs_design() #428

Closed
yuliasidi opened this issue Jun 25, 2024 · 4 comments
Closed

More convenient col_decimals for summary.gs_design() #428

yuliasidi opened this issue Jun 25, 2024 · 4 comments

Comments

@yuliasidi
Copy link
Collaborator

Please consider adding a simplified way for modifying the column digits in the table.
Currently a user needs to run the following code to modify the number of digits for Z value to 4:

tmp_gsDesign2 |>
  summary(
    col_vars = c("analysis", "bound", "z", "~hr at bound", "nominal p", "Alternate hypothesis", "Null hypothesis"),
    col_decimals = c(NA, NA, 4, 4, 4, 4, 4)
  ) 

It would be helpful to have instead the following option and call out only what needs to be modified:

tmp_gsDesign2 |>
  summary(
    col_vars = "z",
    col_decimals = 4
  ) 

For your consideration.

@jdblischak
Copy link
Collaborator

Please consider adding a simplified way for modifying the column digits in the table.

We recently updated the syntax for modifying the number of digits via analysis_decimals (#388, #403), and we plan to update col_decimals similarly.

It would be helpful to have instead the following option and call out only what needs to be modified:

Your proposed syntax isn't possible because col_vars is also used to subset the displayed columns. Thus col_vars = "z" would result in only the z column being displayed. For the analogous analysis_decimals, we updated it to accept a named vector. So in the future the hope is for your example to be possible with:

tmp_gsDesign2 |>
  summary(col_decimals = c(z = 4)) 

Also note that as of last week (#422), you should now be able to omit both "analysis" and "bound", so it at least a bit shorter to type:

tmp_gsDesign2 |>
  summary(
    col_vars = c("z", "~hr at bound", "nominal p", "Alternate hypothesis", "Null hypothesis"),
    col_decimals = c(4, 4, 4, 4, 4)
  ) 

Lastly, I am going to update the title of your Issue. col_vars and col_decimals are arguments to summary.gs_design(), not summary.fixed_design().

@jdblischak jdblischak changed the title decimals in summary.fixed_design() More convenient col_decimals for summary.gs_design() Jun 25, 2024
@yuliasidi
Copy link
Collaborator Author

Thank you, @jdblischak!
I tried the change from the (#422), but I am getting an error:

> gs_power_ahr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) |> summary(col_decimals = c(z = 4))
Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match
In addition: Warning message:
Unknown or uninitialised column: `col_vars`. 
> 
> packageVersion("gsDesign2")
[1] ‘1.1.2.13’

@jdblischak
Copy link
Collaborator

I tried the change from the (#422), but I am getting an error:

@yuliasidi Using col_decimals = c(z = 4) is not possible yet. This Issue is now the placeholder for that new behavior.

#422 allows you to omit "analsysis" and "bound" and their corresponding NAs:

library("gsDesign2")
gs_power_ahr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) |>
  summary(
    col_vars = c("z", "~hr at bound", "nominal p", "Alternate hypothesis", "Null hypothesis"),
    col_decimals = c(4, 4, 4, 4, 4)
  )
## Adding missing grouping variables: `Analysis`
## # A tibble: 6 × 7
## # Groups:   Analysis [3]
##   Analysis      Bound      Z `~HR at bound` `Nominal p` `Alternate hypothesis` `Null hypothesis`
##   <chr>         <chr>  <dbl>          <dbl>       <dbl>                  <dbl>             <dbl>
## 1 Analysis: 1 … Futi… -1.17           1.54       0.879                  0.0349            0.121 
## 2 Analysis: 1 … Effi…  2.67           0.374      0.0038                 0.0231            0.0038
## 3 Analysis: 2 … Futi… -0.663          1.24       0.746                  0.0668            0.266 
## 4 Analysis: 2 … Effi…  2.29           0.481      0.011                  0.0897            0.0122
## 5 Analysis: 3 … Futi… -0.227          1.07       0.590                  0.101             0.430 
## 6 Analysis: 3 … Effi…  2.03           0.560      0.0211                 0.207             0.025

@LittleBeannie
Copy link
Collaborator

Hi @yuliasidi , thanks for exploring the decimal display of the summary function. It looks like your question is solved in the above discussion. I understand the current version of summary does exist some inconvenience of displaying digits, and @jdblischak is actively working on this (see the open issue #430). We will keep you posted once we finished.

Hi @jdblischak, I created an issue (#430) to remind us of the col_decimals in summary(), and assigned this issue to you. Please reach out me if anywhere I could assist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants