transfer from old repo
This commit is contained in:
parent
cfa4a5f9cc
commit
277e2b8cf3
1111 changed files with 83736 additions and 0 deletions
41
1 PA Decline/table mods.R
Normal file
41
1 PA Decline/table mods.R
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
source(here::here("1 PA Decline/dst import.R"))
|
||||
ls_tbl <- docx2ds(
|
||||
path = "/Users/au301842/Library/CloudStorage/OneDrive-Personal/Research/PhD/1 Change in PA/Manuscript/Manuscript_Change in PA_v2_10_IJS.docx"
|
||||
)
|
||||
|
||||
ls <- ls_tbl |> purrr::pluck(3) |>
|
||||
(\(.x){
|
||||
.x[-c(1:3,nrow(.x)),]
|
||||
})()
|
||||
|
||||
ls |> setNames(1:5) |>
|
||||
dplyr::mutate(dplyr::across(2:5,as.numeric)) |>
|
||||
gt::gt() |> gt::fmt_number(n_sigfig=3) |> gt::gtsave("modtable3.docx")
|
||||
|
||||
|
||||
|
||||
ls |> setNames(1:5) |>
|
||||
dplyr::mutate(dplyr::across(2:5, \(.x){
|
||||
as.character(sprintf('%#.3g', as.numeric(.x)))
|
||||
})) |> kableExtra::kable()
|
||||
|
||||
|
||||
## Splitting by leveled variables (expanded view with all levels)
|
||||
n <- 0
|
||||
for (i in seq_len(nrow(ls))){
|
||||
if (ls[[2]][i]!=""){
|
||||
n[i]<-n[length(n)]+1
|
||||
} else {
|
||||
n[i] <- n[length(n)]
|
||||
}
|
||||
}
|
||||
|
||||
split(ls,n) |> lapply(function(.x){
|
||||
|
||||
if (" TRUE" %in% .x[[1]]){
|
||||
cbind(.x[1,1:2],.x[3,3:5],.x[1,6],.x[3,7:9])
|
||||
} else {
|
||||
.x
|
||||
}
|
||||
}) |> dplyr::bind_rows() |>
|
||||
gt::gt()
|
||||
Loading…
Reference in a new issue