-
Notifications
You must be signed in to change notification settings - Fork 14
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
Passing *.stats options when using summary.tableby or as.data.frame.tableby #357
Comments
Thanks for the feedback and I'm glad that you've found the package useful. There are probably several places were the documentation can be improved at this point, and you've pointed out one issue that can be confusing. Basically, think of things like numeric.stats and numeric.test as calculations that need to be run, so they only work in the call the tableby, whereas labels impact the display of information and can be modified in the summary call.
…________________________________
From: jwilliman ***@***.***>
Sent: Thursday, October 20, 2022 6:04 PM
To: mayoverse/arsenal ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [EXTERNAL] [mayoverse/arsenal] Passing *.stats options when using summary.tableby or as.data.frame.tableby (Issue #357)
Great package thanks :) tableby is my go to creating summary tables of patient characteristics.
I'm using tableby within a function and it isn't clear to me from the documentation whether it is meant to be possible to use *.stats arguments (eg. numeric.stats or cat.stats), from within the summary.tableby or as.data.frame.tableby functions? The documentation seems to imply these arguments will be passed via ... to tableby.control, but I assume they are enacted in the original tableby call and can't be changed? Whereas the stats.labels command does act within the summary function?
It would be helpful to be clearer which tableby.control arguments can only be used in tableby and which can (also) be used in summary.tableby and as.data.frame.tableby, and perhaps flag users when they had used an argument in the wrong function.
Thanks
library(arsenal)
set.seed(100)
## make 3+ categories for response
nsubj <- 90
mdat <- data.frame(Response=sample(c(1,2,3),nsubj, replace=TRUE),
Sex=sample(c("Male", "Female"), nsubj,replace=TRUE),
Age=round(rnorm(nsubj,mean=40, sd=5)),
HtIn=round(rnorm(nsubj,mean=65,sd=5)))
## allow default summaries on RHS variables
out <- tableby(Response ~ Sex + Age + HtIn, data=mdat)
summary(out, numeric.stats = "medianq1q3", stats.labels=c(meansd="Mean-SD", q1q3 = "Q1-Q3"), text=TRUE)
#>
#>
#> | | 1 (N=25) | 2 (N=31) | 3 (N=34) | Total (N=90) | p value|
#> |:----------|:---------------:|:---------------:|:---------------:|:---------------:|-------:|
#> |Sex | | | | | 0.232|
#> |- Female | 17 (68.0%) | 14 (45.2%) | 19 (55.9%) | 50 (55.6%) | |
#> |- Male | 8 (32.0%) | 17 (54.8%) | 15 (44.1%) | 40 (44.4%) | |
#> |Age | | | | | 0.547|
#> |- Mean-SD | 40.200 (4.021) | 40.161 (3.796) | 39.265 (3.671) | 39.833 (3.796) | |
#> |- Range | 29.000 - 48.000 | 33.000 - 51.000 | 30.000 - 48.000 | 29.000 - 51.000 | |
#> |HtIn | | | | | 0.093|
#> |- Mean-SD | 63.360 (5.322) | 66.516 (4.878) | 65.000 (5.684) | 65.067 (5.402) | |
#> |- Range | 52.000 - 78.000 | 57.000 - 78.000 | 50.000 - 79.000 | 50.000 - 79.000 | |
as.data.frame(out, numeric.stats = "medianq1q3", stats.labels=c(meansd="Mean-SD", q1q3 = "Q1-Q3"))
#> group.term group.label strata.term variable term label variable.type
#> 1 Response Response Sex Sex Sex categorical
#> 2 Response Response Sex countpct Female categorical
#> 3 Response Response Sex countpct Male categorical
#> 4 Response Response Age Age Age numeric
#> 5 Response Response Age meansd Mean-SD numeric
#> 6 Response Response Age range Range numeric
#> 7 Response Response HtIn HtIn HtIn numeric
#> 8 Response Response HtIn meansd Mean-SD numeric
#> 9 Response Response HtIn range Range numeric
#> 1 2 3
#> 1
#> 2 17, 68 14.00000, 45.16129 19.00000, 55.88235
#> 3 8, 32 17.00000, 54.83871 15.00000, 44.11765
#> 4
#> 5 40.200000, 4.020779 40.161290, 3.795583 39.264706, 3.670594
#> 6 29, 48 33, 51 30, 48
#> 7
#> 8 63.360000, 5.321967 66.516129, 4.877643 65.000000, 5.683575
#> 9 52, 78 57, 78 50, 79
#> Total test p.value
#> 1 Pearson's Chi-squared test 0.23154962
#> 2 50.00000, 55.55556 Pearson's Chi-squared test 0.23154962
#> 3 40.00000, 44.44444 Pearson's Chi-squared test 0.23154962
#> 4 Linear Model ANOVA 0.54654036
#> 5 39.833333, 3.796065 Linear Model ANOVA 0.54654036
#> 6 29, 51 Linear Model ANOVA 0.54654036
#> 7 Linear Model ANOVA 0.09288762
#> 8 65.066667, 5.402455 Linear Model ANOVA 0.09288762
#> 9 50, 79 Linear Model ANOVA 0.09288762
Created on 2022-10-21 by the reprex package<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Freprex.tidyverse.org%2F&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=32JSDtukxaEtQcmfXBDZMQHkDf%2FJIcHFwnjghyZgLs0%3D&reserved=0> (v2.0.1)
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmayoverse%2Farsenal%2Fissues%2F357&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Sf9dHUfzygTB58mJr%2Bbvc8oXL0L951W5yIXuQ4KHh9g%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACWQG57MYB4TUDIMK5CNHBLWEHFXTANCNFSM6AAAAAARKTZHNU&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=F5Us4YxwMt%2Bmr4FfVUmn3MhbBbP0v%2B33BnsIxTJ4DUo%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Thanks for the clarification Beth
There are only so many hours in a day, and I appreciate you taking the time to reply!
Ngā mihi,
Jonathan
Tel / waea: (03) 364-3606. Friday (03) 364 1199
From: Beth Atkinson ***@***.***>
Sent: Saturday, 22 October 2022 4:27 am
To: mayoverse/arsenal ***@***.***>
Cc: Jonathan Williman ***@***.***>; Author ***@***.***>
Subject: Re: [mayoverse/arsenal] Passing *.stats options when using summary.tableby or as.data.frame.tableby (Issue #357)
Thanks for the feedback and I'm glad that you've found the package useful. There are probably several places were the documentation can be improved at this point, and you've pointed out one issue that can be confusing. Basically, think of things like numeric.stats and numeric.test as calculations that need to be run, so they only work in the call the tableby, whereas labels impact the display of information and can be modified in the summary call.
…________________________________
From: jwilliman ***@***.***<mailto:***@***.***>>
Sent: Thursday, October 20, 2022 6:04 PM
To: mayoverse/arsenal ***@***.***<mailto:***@***.***>>
Cc: Subscribed ***@***.***<mailto:***@***.***>>
Subject: [EXTERNAL] [mayoverse/arsenal] Passing *.stats options when using summary.tableby or as.data.frame.tableby (Issue #357)
Great package thanks :) tableby is my go to creating summary tables of patient characteristics.
I'm using tableby within a function and it isn't clear to me from the documentation whether it is meant to be possible to use *.stats arguments (eg. numeric.stats or cat.stats), from within the summary.tableby or as.data.frame.tableby functions? The documentation seems to imply these arguments will be passed via ... to tableby.control, but I assume they are enacted in the original tableby call and can't be changed? Whereas the stats.labels command does act within the summary function?
It would be helpful to be clearer which tableby.control arguments can only be used in tableby and which can (also) be used in summary.tableby and as.data.frame.tableby, and perhaps flag users when they had used an argument in the wrong function.
Thanks
library(arsenal)
set.seed(100)
## make 3+ categories for response
nsubj <- 90
mdat <- data.frame(Response=sample(c(1,2,3),nsubj, replace=TRUE),
Sex=sample(c("Male", "Female"), nsubj,replace=TRUE),
Age=round(rnorm(nsubj,mean=40, sd=5)),
HtIn=round(rnorm(nsubj,mean=65,sd=5)))
## allow default summaries on RHS variables
out <- tableby(Response ~ Sex + Age + HtIn, data=mdat)
summary(out, numeric.stats = "medianq1q3", stats.labels=c(meansd="Mean-SD", q1q3 = "Q1-Q3"), text=TRUE)
#>
#>
#> | | 1 (N=25) | 2 (N=31) | 3 (N=34) | Total (N=90) | p value|
#> |:----------|:---------------:|:---------------:|:---------------:|:---------------:|-------:|
#> |Sex | | | | | 0.232|
#> |- Female | 17 (68.0%) | 14 (45.2%) | 19 (55.9%) | 50 (55.6%) | |
#> |- Male | 8 (32.0%) | 17 (54.8%) | 15 (44.1%) | 40 (44.4%) | |
#> |Age | | | | | 0.547|
#> |- Mean-SD | 40.200 (4.021) | 40.161 (3.796) | 39.265 (3.671) | 39.833 (3.796) | |
#> |- Range | 29.000 - 48.000 | 33.000 - 51.000 | 30.000 - 48.000 | 29.000 - 51.000 | |
#> |HtIn | | | | | 0.093|
#> |- Mean-SD | 63.360 (5.322) | 66.516 (4.878) | 65.000 (5.684) | 65.067 (5.402) | |
#> |- Range | 52.000 - 78.000 | 57.000 - 78.000 | 50.000 - 79.000 | 50.000 - 79.000 | |
as.data.frame(out, numeric.stats = "medianq1q3", stats.labels=c(meansd="Mean-SD", q1q3 = "Q1-Q3"))
#> group.term group.label strata.term variable term label variable.type
#> 1 Response Response Sex Sex Sex categorical
#> 2 Response Response Sex countpct Female categorical
#> 3 Response Response Sex countpct Male categorical
#> 4 Response Response Age Age Age numeric
#> 5 Response Response Age meansd Mean-SD numeric
#> 6 Response Response Age range Range numeric
#> 7 Response Response HtIn HtIn HtIn numeric
#> 8 Response Response HtIn meansd Mean-SD numeric
#> 9 Response Response HtIn range Range numeric
#> 1 2 3
#> 1
#> 2 17, 68 14.00000, 45.16129 19.00000, 55.88235
#> 3 8, 32 17.00000, 54.83871 15.00000, 44.11765
#> 4
#> 5 40.200000, 4.020779 40.161290, 3.795583 39.264706, 3.670594
#> 6 29, 48 33, 51 30, 48
#> 7
#> 8 63.360000, 5.321967 66.516129, 4.877643 65.000000, 5.683575
#> 9 52, 78 57, 78 50, 79
#> Total test p.value
#> 1 Pearson's Chi-squared test 0.23154962
#> 2 50.00000, 55.55556 Pearson's Chi-squared test 0.23154962
#> 3 40.00000, 44.44444 Pearson's Chi-squared test 0.23154962
#> 4 Linear Model ANOVA 0.54654036
#> 5 39.833333, 3.796065 Linear Model ANOVA 0.54654036
#> 6 29, 51 Linear Model ANOVA 0.54654036
#> 7 Linear Model ANOVA 0.09288762
#> 8 65.066667, 5.402455 Linear Model ANOVA 0.09288762
#> 9 50, 79 Linear Model ANOVA 0.09288762
Created on 2022-10-21 by the reprex package<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Freprex.tidyverse.org%2F&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=32JSDtukxaEtQcmfXBDZMQHkDf%2FJIcHFwnjghyZgLs0%3D&reserved=0> (v2.0.1)
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmayoverse%2Farsenal%2Fissues%2F357&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Sf9dHUfzygTB58mJr%2Bbvc8oXL0L951W5yIXuQ4KHh9g%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACWQG57MYB4TUDIMK5CNHBLWEHFXTANCNFSM6AAAAAARKTZHNU&data=05%7C01%7Catkinson%40mayo.edu%7C3614480e20b1419540ca08dab2ef79c0%7Ca25fff9c3f634fb29a8ad9bdd0321f9a%7C0%7C0%7C638019038854230613%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=F5Us4YxwMt%2Bmr4FfVUmn3MhbBbP0v%2B33BnsIxTJ4DUo%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***<mailto:***@***.***>>
—
Reply to this email directly, view it on GitHub<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmayoverse%2Farsenal%2Fissues%2F357%23issuecomment-1287120606&data=05%7C01%7Cjonathan.williman%40otago.ac.nz%7C019d97fe6bfe4719486608dab378a6ec%7C0225efc578fe4928b1579ef24809e9ba%7C0%7C0%7C638019628070452500%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pSlcZfDNomDqYMr8FkJRqqwitIq8dPx4dOe0owjb3nw%3D&reserved=0>, or unsubscribe<https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAESTYJKXBCU244RR7DST3A3WEKY25ANCNFSM6AAAAAARKTZHNU&data=05%7C01%7Cjonathan.williman%40otago.ac.nz%7C019d97fe6bfe4719486608dab378a6ec%7C0225efc578fe4928b1579ef24809e9ba%7C0%7C0%7C638019628070452500%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=iVSkq2Urpm9QxCWKp5S7mKNZNJ2EhfT5qikYwAH%2Fzqc%3D&reserved=0>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great package thanks :)
tableby
is my go to creating summary tables of patient characteristics.I'm using
tableby
within a function and it isn't clear to me from the documentation whether it is meant to be possible to use*.stats
arguments (eg.numeric.stats
orcat.stats
), from within thesummary.tableby
oras.data.frame.tableby
functions? The documentation seems to imply these arguments will be passed via...
totableby.control
, but I assume they are enacted in the originaltableby
call and can't be changed? Whereas thestats.labels
command does act within thesummary
function?It would be helpful to be clearer which
tableby.control
arguments can only be used intableby
and which can (also) be used insummary.tableby
andas.data.frame.tableby
, and perhaps flag users when they had used an argument in the wrong function.Thanks
Created on 2022-10-21 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: