Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
1750668
Merge pull request #1 from lampk/master
trinhdhk Sep 17, 2019
ead15e2
Fix sstable.baseline not summarising z
trinhdhk Sep 17, 2019
3b2ed5f
Merge branch 'master' of https://github.com/oucru-biostats/C306
trinhdhk Sep 17, 2019
829a137
Add the ability for sstable.ae to categorise aes into group, designat…
trinhdhk Sep 19, 2019
ea50a65
Fix sstable.ae
trinhdhk Sep 20, 2019
3287d55
Add help details to sstable.ae$chisq.test.
trinhdhk Sep 20, 2019
a3d69fa
New functions for formatting sstable (when flextable == FALSE)
trinhdhk Sep 27, 2019
cd45c54
Hot fix for ssformat
trinhdhk Sep 27, 2019
4c75b92
Add caption feature for ss_huxtable
trinhdhk Sep 27, 2019
ae3da25
Hot fix for ht_theme_markdown
trinhdhk Sep 27, 2019
0d8ac80
Add new function: simple_relevel. Tweaks for ss_huxtable
trinhdhk Oct 1, 2019
1ff86df
Fix for ungrouped ae_tbl. Add ability to keep empty group in baseline…
trinhdhk Oct 2, 2019
49c6622
fix for ss_huxtable
trinhdhk Oct 2, 2019
b306130
Enable quick wrap for huxtable
trinhdhk Oct 2, 2019
21af385
New theme kable
trinhdhk Oct 3, 2019
8731695
Fix sstable.ae
trinhdhk Oct 3, 2019
f2cb924
Fix ssformat. Fix continuous z summary in sstable.baseline
trinhdhk Oct 6, 2019
1624b83
Disable auto-sort when arm is a factor. It's not appropriate to do so.
trinhdhk Oct 7, 2019
4743d9e
Fix sstable problem with tibble.
trinhdhk Oct 7, 2019
b086aca
Merge pull request #2 from oucru-biostats/experimental
trinhdhk Nov 7, 2019
0ca9549
Fix bug in sstable.ae. Update to roxygen2 7
trinhdhk Nov 19, 2019
3e616d6
Add maintainers.
trinhdhk Nov 19, 2019
e9f579d
Add logist_summary, now with lik.ratio p.value for interaction model.…
trinhdhk Nov 26, 2019
4ec0648
Add pct for calculating percentages. Add ref_lv to quickly get and se…
trinhdhk Nov 26, 2019
d352085
Help for logist_summary
trinhdhk Nov 26, 2019
84f6ce0
Update README.md
trinhdhk Nov 26, 2019
91c357f
Fix typos in logist_summary and simple_relevel
trinhdhk Nov 27, 2019
6f9b456
fix typo in logist_summary help file
trinhdhk Nov 27, 2019
d5dc78c
Fit bugs in explicit()
trinhdhk Nov 29, 2019
773a557
Merge branch 'experimental' of https://github.com/oucru-biostats/C306…
trinhdhk Nov 29, 2019
2fbd66b
Fit bugs in logist_summary. Remove the name_matching feature. Use the…
trinhdhk Nov 29, 2019
5df7ea6
logist_summary: add sstable output. add support for summary_tbl in ss…
trinhdhk Dec 2, 2019
130eab3
Depricated function
trinhdhk Dec 2, 2019
0863f69
Add as_sstable
trinhdhk Dec 2, 2019
d492b97
Add overlap_join. Up to version 0.1.5
trinhdhk Dec 3, 2019
d25a6e1
Add overlap_summary.
trinhdhk Dec 3, 2019
4b68c38
Fix a bug in logist_summary when flextable is not respected
trinhdhk Dec 3, 2019
59dfa9b
Separate overlap function to rangemisc, new _f functions
trinhdhk Dec 17, 2019
4345564
Fix bugs in logist_summary, now work with environment-typed data
trinhdhk Dec 18, 2019
6c1a208
Add support for new data
trinhdhk Dec 19, 2019
a8a104a
New algorithm for lik.ratio test
trinhdhk Dec 24, 2019
5b44416
Add subgroup_effect to summarise covariable effect within each state …
trinhdhk Dec 26, 2019
97b9f83
remove cached
trinhdhk Dec 26, 2019
ccf1012
restore
trinhdhk Dec 26, 2019
32e6fb8
Add transpose method for subgroup_effect
trinhdhk Dec 30, 2019
486dd7c
Edit readme
trinhdhk Dec 30, 2019
a57acbd
Documentation polishment
trinhdhk Dec 31, 2019
ae205cd
New function gg_boxcox
trinhdhk Jan 17, 2020
09765ae
Fix subsetting subgroup_logist_summary table
trinhdhk Jan 17, 2020
28825bd
Up to 202001 build
trinhdhk Jan 17, 2020
7736735
Up to build 202001
trinhdhk Jan 17, 2020
192b51e
Add formula.tools as dependencies
trinhdhk Jan 17, 2020
4c98ffe
Hot fix for gg_boxcox
trinhdhk Jan 20, 2020
0a24f4a
Update DESCRIPTION
trinhdhk Apr 17, 2020
704112c
Update README.md
trinhdhk Sep 28, 2020
fedec1c
add createProject2
lampk Dec 3, 2020
3b25d85
update NAMESPACE
lampk Dec 3, 2020
7d30d14
fix replace_na stop allow auto type-coercing in 1.2.0
trinhdhk Apr 28, 2022
55307ef
fix replace_na disabling auto type-coercing in tidyr 1.2.0
trinhdhk Apr 28, 2022
6fae4b4
fix explicit.R
trinhdhk Apr 4, 2024
b67b658
fix survival not accepting Inf as time
trinhdhk May 3, 2024
32c67ad
Merge pull request #3 from trinhdhk/experimental
trinhdhk May 3, 2024
5a1af32
fix P(>Chi) -> Pr(>Chi)
trinhdhk May 3, 2024
3a15f1d
Merge pull request #4 from trinhdhk/experimental
trinhdhk May 3, 2024
e1d9b88
as_sstable.list now support syntax of list
trinhdhk May 7, 2024
550539d
typo
trinhdhk May 7, 2024
bb7b378
typo
trinhdhk May 7, 2024
aaed326
add flexable=TRUE for as_sstable.list
trinhdhk May 7, 2024
e79bc50
Fix bugs for ss_format. Add a helper for format flextable in sstable …
trinhdhk Jun 12, 2024
869429c
add RMST to survcomp
trinhdhk Jun 13, 2024
99e06cb
add documentation
trinhdhk Jun 13, 2024
a53a9f5
fix bug ft_sstheme
trinhdhk Jun 14, 2024
9c95e5a
fix bug ft_sstheme
trinhdhk Jun 14, 2024
7a568dc
fix bug ft_sstheme
trinhdhk Jun 14, 2024
a97e260
fix bug for ff_sstheme
trinhdhk Jun 14, 2024
0abae48
reverse the level for comparison
trinhdhk Jun 14, 2024
3e3cba7
add time arg to descriptive
trinhdhk Jun 14, 2024
abc079b
update docs
trinhdhk Jun 14, 2024
7317834
Update sstable.R
trinhdhk Jun 14, 2024
8b7644d
the summary table always returns at Inf
trinhdhk Jun 14, 2024
870fb13
add `time` for subgroup
trinhdhk Jun 14, 2024
0b15ced
fix detection of arm.vars
trinhdhk Jun 17, 2024
38e3952
fix survcomp
trinhdhk Jun 17, 2024
3ddae28
Update sstable.R
trinhdhk Jun 17, 2024
98a7889
Update sstable.R
trinhdhk Jun 17, 2024
9bad5a5
Fix type of rmst
trinhdhk Jun 17, 2024
cbe10dc
add cuminc regression
trinhdhk Jun 17, 2024
20aafa3
fix printing method
trinhdhk Jun 17, 2024
79553af
Update sstable.R
trinhdhk Jun 17, 2024
c4f480a
add rmtl loss because why not
trinhdhk Jun 18, 2024
37769dc
Update sstable.R
trinhdhk Jun 18, 2024
61f75a7
Update sstable.R
trinhdhk Jun 18, 2024
8e10b0b
fix ae table
trinhdhk Jun 19, 2024
aa97e1f
changing iconv to stri_trans_general
trinhdhk Jun 19, 2024
0f219ce
Update sstable.baseline.Rd
trinhdhk Jun 19, 2024
5535563
fix mismatch id in conditional checking
trinhdhk Jun 19, 2024
9871344
typo condition -> tmpcondition
trinhdhk Jun 19, 2024
9acbd33
fix tmprow
trinhdhk Jun 19, 2024
7f78a6e
???
trinhdhk Jun 19, 2024
7f9c2de
fix double reversal of level in sstable.baseline
trinhdhk Jun 20, 2024
17a757d
add gg_ajsurvplot
trinhdhk Jun 20, 2024
4a21726
optional p.value for comparison in survcomp
trinhdhk Jun 20, 2024
b89f64b
add rbind and ajsruvplot2
trinhdhk Jun 25, 2024
46ef660
fix wrong class
trinhdhk Jun 25, 2024
ef58d3c
fix all.equal
trinhdhk Jun 25, 2024
25f2186
fix issue with rbind ae_tbl
trinhdhk Jun 25, 2024
3d52b65
Update DESCRIPTION
trinhdhk Jun 26, 2024
3a81e34
Update DESCRIPTION
trinhdhk Jun 26, 2024
892a850
Update DESCRIPTION
trinhdhk Jun 26, 2024
54b3591
fix flextable true
trinhdhk Jun 26, 2024
949084e
Update documentation
trinhdhk Jun 26, 2024
c4dedc7
Update documentation
trinhdhk Jun 26, 2024
6a71b69
fix typo in footer
TranHung93 Jul 1, 2024
f3f05b9
Merge pull request #5 from TranHung93/feature-rbind
TranHung93 Jul 1, 2024
c2a981f
Update sstable.R
TranHung93 Jul 1, 2024
3fe77cb
Merge pull request #6 from TranHung93/feature-rbind
TranHung93 Jul 1, 2024
dc2170d
upload data for vignette
TranHung93 Jul 1, 2024
8cf5185
put data in correct place
TranHung93 Jul 1, 2024
26859a8
update data
TranHung93 Jul 1, 2024
1b66abf
add data
TranHung93 Jul 1, 2024
0b2547d
delet wrong data
TranHung93 Jul 2, 2024
c654960
Delete ae_data.csv
TranHung93 Jul 2, 2024
ef49865
Delete group_data.csv
TranHung93 Jul 2, 2024
2146fa7
Delete baseline_data.csv
TranHung93 Jul 2, 2024
8df6e52
Merge pull request #8 from TranHung93/feature-rbind
trinhdhk Jul 2, 2024
4dae3a1
Merge pull request #9 from TranHung93/feature-testing
trinhdhk Jul 2, 2024
6ec9fe0
Merge branch 'feature-rbind' of https://github.com/oucru-biostats/C30…
trinhdhk Jul 4, 2024
0e56c72
Fix bug in ss_flextable
trinhdhk Jul 4, 2024
7569b76
add method for ss_obj
trinhdhk Jul 4, 2024
62004b4
Removal of missing outcome
trinhdhk Jul 5, 2024
ac3ca05
remove NA for sstable.survcomp
trinhdhk Jul 5, 2024
7fd8930
Update sstable.R
trinhdhk Jul 5, 2024
47ae0e8
Update sstable.R
trinhdhk Jul 5, 2024
60358ce
Update sstable.R
trinhdhk Jul 5, 2024
d29421e
Update sstable.R
TranHung93 Jul 6, 2024
7d53f31
Merge pull request #10 from TranHung93/feature-testing
TranHung93 Jul 6, 2024
7f3884d
Update ae_data.csv
TranHung93 Jul 6, 2024
086b6c2
Merge pull request #11 from TranHung93/feature-testing
TranHung93 Jul 6, 2024
6b7a2ba
updated data for vignette, and updated code for bold the group row
TranHung93 Jul 7, 2024
debd9be
Merge pull request #12 from TranHung93/feature-testing
TranHung93 Jul 7, 2024
6f66d34
fix na.rm in sstable.survcomp dropping labels
trinhdhk Jul 8, 2024
60c48e3
Merge branch 'feature-rbind' of https://github.com/oucru-biostats/C30…
trinhdhk Jul 8, 2024
58adf60
udpate group.var.priority
TranHung93 Jul 8, 2024
0293e9e
Merge pull request #13 from TranHung93/feature-testing
TranHung93 Jul 8, 2024
40aeabd
Adding mstate model to survcomp
trinhdhk Jul 9, 2024
72de669
Merge branch 'feature-rbind' of https://github.com/oucru-biostats/C30…
trinhdhk Jul 9, 2024
36cf9dc
fix typo.
trinhdhk Jul 9, 2024
7ca9be5
fix bug strata gg_ajsurvplot2
trinhdhk Jul 9, 2024
f2037e5
fix survival namespace
trinhdhk Jul 9, 2024
6832296
update aetype.var header
TranHung93 Jul 10, 2024
1c18d21
Merge branch 'feature-rbind' into feature-testing
TranHung93 Jul 10, 2024
be9b2b1
Update sstable.R
TranHung93 Jul 10, 2024
6ade133
Merge branch 'feature-testing' of https://github.com/TranHung93/C306 …
TranHung93 Jul 10, 2024
95bd039
minor changes
TranHung93 Jul 10, 2024
04586a9
fix survival namespace
trinhdhk Jul 9, 2024
7da3a1c
Merge pull request #16 from TranHung93/feature-testing
trinhdhk Jul 10, 2024
03050f9
Recover sstable.survcomp
trinhdhk Jul 10, 2024
3913f66
Update sstable.R
TranHung93 Jul 10, 2024
e395168
Merge pull request #17 from TranHung93/feature-rmst
TranHung93 Jul 10, 2024
a90c918
update use label for baseline table
TranHung93 Jul 10, 2024
667ec83
Merge pull request #18 from TranHung93/feature-rmst
TranHung93 Jul 10, 2024
fb5baa6
debug labeling
TranHung93 Jul 10, 2024
5eb17f1
Merge pull request #19 from TranHung93/feature-rmst
TranHung93 Jul 10, 2024
a595d66
Fix interaction test with subgroup.
trinhdhk Jul 11, 2024
5c7f5dd
Fix missing predictor is survcomp ia.
trinhdhk Jul 11, 2024
44a6c58
add Hmisc dependencies
trinhdhk Jul 11, 2024
ea11cbf
remove p for invalid CI
trinhdhk Jul 11, 2024
6606879
fix typos
trinhdhk Jul 11, 2024
87503d3
fix typos
trinhdhk Jul 11, 2024
040f88d
updated conSummary, mycontSummary, sstable.baseline
TranHung93 Jul 12, 2024
0ee9a9e
switch to multivarWald for RMST heterogeneity test
trinhdhk Jul 12, 2024
41a075b
add dependency on aod
trinhdhk Jul 12, 2024
cd247c7
Merge branch 'feature-rmst' into feature-rmst
trinhdhk Jul 12, 2024
1aa9b79
no header when length(aetype.var)==1
trinhdhk Jul 12, 2024
1814b42
Merge pull request #20 from TranHung93/feature-rmst
trinhdhk Jul 12, 2024
9162c22
add ability to add and remove aetype.header
trinhdhk Jul 12, 2024
fb07768
fix bug aetype.header
trinhdhk Jul 12, 2024
34ee650
fix typos
trinhdhk Jul 12, 2024
0ffc8b6
recover of multivariate Wald test
trinhdhk Jul 12, 2024
1485b6e
improve survcomp
trinhdhk Jul 12, 2024
2e728bc
add overall.model
trinhdhk Jul 12, 2024
e25091f
fix typos
trinhdhk Jul 12, 2024
6d12938
fix typos
trinhdhk Jul 12, 2024
3a547da
temporary fix the overall model
trinhdhk Jul 12, 2024
da074ee
temporary fix overall.model.
trinhdhk Jul 12, 2024
45e18b4
Update sstable.R
TranHung93 Jul 12, 2024
25f6a1c
Merge branch 'feature-rmst' of https://github.com/oucru-biostats/C306…
TranHung93 Jul 12, 2024
5f89cb6
Merge pull request #1 from oucru-biostats/feature-rmst
TranHung93 Jul 12, 2024
5ce80b0
Fix Print.aetype.header not passed to children.
trinhdhk Jul 12, 2024
f59cf33
Merge pull request #21 from TranHung93/feature-rmst
TranHung93 Jul 12, 2024
30e2b8d
Fix grade NA
trinhdhk Jul 12, 2024
18d0e8e
Fix two any
trinhdhk Jul 12, 2024
0a7e913
Merge pull request #2 from oucru-biostats/feature-rmst
TranHung93 Jul 12, 2024
d6fcdda
Update sstable.R
trinhdhk Jul 12, 2024
85be7e6
A confusing fix
trinhdhk Jul 12, 2024
c8ad2d7
Merge pull request #22 from TranHung93/feature-rmst
TranHung93 Jul 12, 2024
f6b0067
Another confusing update
trinhdhk Jul 12, 2024
719ae3f
Update sstable.R
TranHung93 Jul 12, 2024
1b5ef85
Revert "update sstable.baseline.edit"
trinhdhk Jul 13, 2024
9b86576
Merge pull request #23 from oucru-biostats/revert-22-feature-rmst
trinhdhk Jul 13, 2024
e864640
Revert "Update sstable.R"
trinhdhk Jul 15, 2024
515a74d
Revert sstable change and add naming options for aetype.var
trinhdhk Jul 15, 2024
dc389f0
Cleanup code in sstable.ae
trinhdhk Jul 15, 2024
377ea03
pump version to 240715
trinhdhk Jul 15, 2024
52d5fb7
pump version to 240715
trinhdhk Jul 15, 2024
358e38c
Merge branch 'feature-rmst'
trinhdhk Jul 15, 2024
1041ad1
Update README.md
trinhdhk Jul 15, 2024
2beefa0
fix a typo in sstable.ae
trinhdhk Jul 25, 2024
648a0b7
Merge branch '27TB-feature-frozen' of https://github.com/oucru-biosta…
trinhdhk Jul 25, 2024
4065868
Add ci in gg_ajsurvplot2
trinhdhk Jul 26, 2024
72956ae
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
84d87f5
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
bf12d9c
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
c300756
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
87eb358
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
1bcd220
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
57ab901
Update gg_ajsurvplot.R
trinhdhk Jul 26, 2024
7f7e8fc
fix bug of ss_flextable that happens when header row ==1
trinhdhk Aug 5, 2024
ac42c6a
add overlaid type ajsurvplot
trinhdhk Aug 8, 2024
d9632cc
fix small bugs
trinhdhk Aug 8, 2024
6dcc0cf
update non-facetted ajsurvplot
trinhdhk Aug 12, 2024
3ca1c96
Update sstable.R
trinhdhk Aug 19, 2024
d3a9941
fix abs.risk in survcomp
trinhdhk Aug 19, 2024
34fda87
rsmt -> rmtl
trinhdhk Aug 19, 2024
679ca6b
fix RMST RMTL confusion
trinhdhk Aug 19, 2024
d7ee5b8
fix risk table in surv_comp
trinhdhk Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .RDataTmp
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
R/.depricated.R
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"vim.useSystemClipboard": true
}
46 changes: 39 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
Package: C306
Type: Package
Title: Collection of useful R codes for data analysis from the Biostatistics group at OUCRU
Version: 0.1.2
Version: 0.1.5-240715
Author: Lam Phung Khanh
Maintainer: Lam Phung Khanh <phungkhanhlam@gmail.com>
Maintainer@R:
c(
person(
given = "Khanh Lam",
family = "Phung",
role = c("author", "maintainer"),
email = "phungkhanhlam@gmail.com"),
person(
given = "Huu Khanh Trinh",
family = "Dong"
role = "maintainer",
email = "trindhk@oucru.org"),
person(
given = "Biostatistic Group",
role = "maintainer",
email = "biostatistics@oucru.org"
)
)
Description: Collection of useful R codes for data analysis from the Biostatistics group at OUCRU
Use four spaces when indenting paragraphs within the Description.
License: The MIT License (MIT)
Encoding: UTF-8
LazyData: true
Imports: lubridate,
Depends:
data.table,
dplyr,
R (>= 4.1)
Imports:
Hmisc,
stringi,
lubridate,
car,
readxl,
dplyr,
flextable,
officer,
tidyr,
rlang,
purrr,
formula.tools,
eventglm,
ggplot2,
survminer,
ggsurvfit,
survival,
tidyr
RoxygenNote: 6.1.1
aod
RoxygenNote: 7.3.2
Suggests: knitr,
rmarkdown
rmarkdown,
huxtable
VignetteBuilder: knitr
66 changes: 66 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,86 @@
# Generated by roxygen2: do not edit by hand

S3method("[",subgroup_logist_summary)
S3method("ref_lv<-",factor)
S3method(as_sstable,default)
S3method(as_sstable,list)
S3method(as_sstable,logist_summary)
S3method(as_sstable,overlap_summary)
S3method(as_sstable,subgroup_logist_summary)
S3method(explicit,lm)
S3method(gg_boxcox,default)
S3method(gg_boxcox,formula)
S3method(gg_boxcox,lm)
S3method(mutate_f,data.frame)
S3method(mutate_f,data.table)
S3method(mutate_f,grouped_df)
S3method(mutate_f,tbl)
S3method(print,logist_summary)
S3method(print,ss_tbl)
S3method(print,subgroup_logist_summary)
S3method(rbind,ss_ae)
S3method(rbind,ss_baseline)
S3method(rbind,ss_obj)
S3method(rbind,ss_survcomp)
S3method(ref_lv,factor)
S3method(simple_recode,data.frame)
S3method(simple_recode,default)
S3method(simple_relevel,data.frame)
S3method(simple_relevel,default)
S3method(ss_flextable,default)
S3method(ss_flextable,list)
S3method(ss_flextable,ss_obj)
S3method(ss_huxtable,default)
S3method(ss_huxtable,list)
S3method(summarise_f,data.frame)
S3method(summarise_f,data.table)
S3method(summarise_f,grouped_df)
S3method(summarise_f,tbl)
S3method(t,subgroup_logist_summary)
export("ref_lv<-")
export(as_sstable)
export(contSummary)
export(convert.info)
export(createProject)
export(createProject2)
export(explicit)
export(ft_sstheme)
export(getlabel)
export(gg_ajsurvplot)
export(gg_ajsurvplot2)
export(gg_boxcox)
export(ggsurvfit2)
export(ht_theme_kable)
export(ht_theme_markdown)
export(import.info)
export(inspect.data)
export(labAE)
export(logist_summary)
export(mutate_f)
export(myformat.data)
export(pct)
export(ref_lv)
export(simple_recode)
export(simple_relevel)
export(simple_sort)
export(ss_body)
export(ss_flextable)
export(ss_format)
export(ss_header)
export(ss_huxtable)
export(ss_section)
export(ss_template)
export(sstable.ae)
export(sstable.baseline)
export(sstable.baseline.edit)
export(sstable.survcomp)
export(sstable.survcomp.subgroup)
export(subgroup_effect)
export(summarise_f)
export(tidy_competingevent)
export(tidy_survfit2)
import(dplyr)
import(ggplot2)
import(survival)
import(tidyr)
importFrom(data.table,":=")
1 change: 1 addition & 0 deletions R/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.depricated.R
36 changes: 23 additions & 13 deletions R/checking.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ inspect.data <- function (data, info, id, check_missing = c(TRUE, FALSE), plot =
lapply(X = 1:ncol(data),
FUN = function(x) {
tmpdata <- data[, x]
tmprow <- seq_len(nrow(data))
if ("condition" %in% names(info)) {
if (!is.na(info$condition[x])) {
## match variable name is condition
tmpcondition <- find_match_correct_var_final(cond = info$condition[x], realvar = names(data))
tmpdata <- eval(parse(text = paste0("subset(data,", tmpcondition, ")[, x]")))
tmprow <- with(data, which(eval(parse(text=tmpcondition))))
}
}
inspect.each(x = tmpdata,
id = tmprow,
varname = info$varname[x],
value = info$value[x],
type = info$type[x],
Expand All @@ -94,8 +97,11 @@ inspect.data <- function (data, info, id, check_missing = c(TRUE, FALSE), plot =
N <- nrow(data)
for (i in (1:length(info$varname))) {
tmpdata <- data[, names(data)[tolower(names(data)) == tolower(info$varname[i])]]
tmplabel <- substr(gsub(pattern = "[\x01-\x1f\x7f-\xff:]", replacement = "",
x = info$label[i]), start = 1, stop = 30)
# tmplabel <- substr(gsub(pattern = "[\x01-\x1f\x7f-\xff:]", replacement = "",
# x = info$label[i]), start = 1, stop = 30)
tmplabel <- substr(stringi::stri_trans_general(
info$label[i],
id="Latin-ASCII"), start=1, stop=30) |> gsub("?", "", x=_, fixed=TRUE)
if (length(na.omit(tmpdata)) == 0) {
plot(x = 1:10, y = 1:10,
main = paste(info$varname[i], "\n (", tmplabel, ")", " \n (", info$type[i], ")", sep = ""),
Expand All @@ -109,8 +115,12 @@ inspect.data <- function (data, info, id, check_missing = c(TRUE, FALSE), plot =
x <- barplot(table(tmpdata),
main = paste(info$varname[i], "\n (", tmplabel, ")", " \n (", info$type[i], ", N=", N, ", missing=", nNA, ")", sep = ""),
xaxt = "n")
labs <- substr(gsub(pattern = "[\x01-\x1f\x7f-\xff:]", replacement = "",
x = names(table(tmpdata))), start = 1, stop = 10)
# labs <- substr(gsub(pattern = "[\x01-\x1f\x7f-\xff:]", replacement = "",
# x = names(table(tmpdata))), start = 1, stop = 10)
labs <- substr(gsub(pattern = "?", replacement = "", fixed=TRUE,
x = stringi::stri_trans_general(
names(table(tmpdata)),
id="Latin-ASCII")), start = 1, stop = 10)
text(cex = 1, x = x, y = 0, labs, xpd = TRUE, srt = 45, adj = 1)
}
else {
Expand All @@ -137,25 +147,25 @@ inspect.data <- function (data, info, id, check_missing = c(TRUE, FALSE), plot =
}
}

inspect.each <- function (x, varname, type, value = NA, check_missing = TRUE) {
inspect.each <- function (x, id, varname, type, value = NA, check_missing = TRUE) {
tmp <- NULL
if (check_missing) {
if (anyNA(x) | any(as.character(x) == "")) {
tmp <- rbind(tmp, data.frame(index = which(is.na(x) |
as.character(x) == ""), error = paste("Missing value for",
tmp <- rbind(tmp, data.frame(index = id[is.na(x) |
as.character(x) == ""], error = paste("Missing value for",
varname)))
}
}
if (type == "numeric" & (!is.na(value) & value != "")) {
range <- as.numeric(unlist(strsplit(value, split = ";")))
if (any(x < range[1] & !is.na(x))) {
tmp <- rbind(tmp, data.frame(index = which(!is.na(x) &
x < range[1]), error = paste("Out of range:",
tmp <- rbind(tmp, data.frame(index = id[!is.na(x) &
x < range[1]], error = paste("Out of range:",
varname, "<", range[1])))
}
if (any(x > range[2] & !is.na(x))) {
tmp <- rbind(tmp, data.frame(index = which(!is.na(x) &
x > range[2]), error = paste("Out of range:",
tmp <- rbind(tmp, data.frame(index = id[!is.na(x) &
x > range[2]], error = paste("Out of range:",
varname, ">", range[2])))
}
}
Expand All @@ -165,8 +175,8 @@ inspect.each <- function (x, varname, type, value = NA, check_missing = TRUE) {
USE.NAMES = FALSE)
if (any(!x %in% range & !is.na(x))) {
xx <- x[!is.na(x) & !x %in% range]
tmp <- rbind(tmp, data.frame(index = which(!is.na(x) &
!x %in% range), error = paste("Out of range:",
tmp <- rbind(tmp, data.frame(index = id[!is.na(x) &
!x %in% range], error = paste("Out of range:",
varname, "=", xx)))
}
}
Expand Down
23 changes: 23 additions & 0 deletions R/createProject.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,27 @@ createProject <- function(dir, structure = c("OUCRU_RCT_wInterim")){
# inform
cat(paste("Project", basename(dir), "was created in", dirname(dir), "\n", sep = " "))
}
#' @export
createProject2 <- function(dir, structure = c("Project")){
## to create project directory
## initial version: 23 July 2015

if (length(structure) > 1) {structure <- "Project"}

## create destination folder
dir.create(dir)

## copy folder structure into destination folder
file.copy(from = file.path(system.file(package = "C306"), "structure", structure, "."),
to = dir, recursive = TRUE)
file.rename(from = file.path(dir, "Analysis"), to = file.path(dir, paste0(basename(dir), "_Analysis")))
file.rename(from = file.path(dir, "Published"), to = file.path(dir, paste0(basename(dir), "_Published")))

## populate workflowr
if ("workflowr" %in% rownames(installed.packages())) {
workflowr::wflow_start(file.path(dir, paste0(basename(dir), "_Published")), existing = TRUE, overwrite = TRUE)
}

# inform
cat(paste("Project", basename(dir), "was created in", dirname(dir), "\n", sep = " "))
}
54 changes: 54 additions & 0 deletions R/explicit.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#' Transform an object to its explicit form
#' @description A function to transform an object to its explicit form if possible
#' @param x An object
#' @seealso \link{explicit.lm}
#' @export
explicit <- function(x, ...){
UseMethod('explicit')
}

#' Transform a model to its explicit form
#' @description
#' A function to transform an lm model formula to its explicit form.
#' This is useful when you want to use stats::drop1 to drop additional terms in interaction models.
#' @param fit An object of class "lm"
#' @examples
#' iris.model <- lm(Sepal.Width ~ Sepal.Length*Petal.Width, data=iris)
#' explicit(iris.model)
#' @return A model with explicit formula
#' @seealso \link[stats]{add1}
#' @export
explicit.lm <- function(fit){
._explicit_lm(fit, data = data, .meta = FALSE)
# if (length(data)) new_fit$call$data <- rlang::sym(deparse(substitute(data)))
# new_fit
}

._explicit_lm <- function(lm, .meta = FALSE, ...)
{
formula <- formula(lm)
mf <- match.call(expand.dots = FALSE)
m <- match(c("lm", "data", "weights", "na.action",
"offset"), names(mf), 0L)
mf <- mf[c(1, m)]
mf$drop.unused.levels <- TRUE
# browser()
mf[[1L]] <- as.name("model.frame")
names(mf)[2L] <- "formula"
mf <- eval(mf, parent.frame())
y <- model.response(mf)
x <- model.matrix(lm)
new_data <- cbind(mf, model.matrix(lm)[,!colnames(x) %in% c('(Intercept)', colnames(mf)), drop=FALSE])
x_names <- paste0('`', gsub('(^`)|(`$)', '', colnames(x)[-1]), '`')
names(x_names) <- colnames(x)[-1]
# browser()
new_fml <- formula(call('~',
parse(text = paste(x_names,
collapse = '+'),
keep.source = FALSE)[[1L]]
))
new_lm <- update(lm, new_fml, data = new_data)
new_lm$call$data <- lm$call$data
if (.meta) attr(new_lm, 'name.map') <- structure(names(x_names), names = unname(x_names))
return(new_lm)
}
Loading