41 lines
966 B
R
41 lines
966 B
R
|
|
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()
|