Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
name: coverage-test-failures-${{ runner.temp }}
path: ${{ runner.temp }}/package
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ Imports:
lubridate,
R6,
ggplot2,
ggraph
Depends:
data.table
ggraph,
data.table
RoxygenNote: 7.3.2
Suggests:
knitr,
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ import(ggplot2)
import(ggraph)
import(igraph)
importFrom(R6,R6Class)
importFrom(data.table,":=")
importFrom(data.table,.BY)
importFrom(data.table,.EACHI)
importFrom(data.table,.GRP)
importFrom(data.table,.I)
importFrom(data.table,.N)
importFrom(data.table,.NGRP)
importFrom(data.table,.SD)
importFrom(data.table,data.table)
importFrom(stats,rnorm)
9 changes: 5 additions & 4 deletions R/DataManagement.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#' @examples
#' ## create a "fake and custom" data base
#' mydb = create_fake_subjectDB(n_subjects = 100, n_facilities = 100)
#' setnames(mydb, 1:4, c("myPatientId", "myHealthCareCenterID", "DateOfAdmission", "DateOfDischarge"))
#' data.table::setnames(mydb, 1:4,
#' c("myPatientId", "myHealthCareCenterID", "DateOfAdmission", "DateOfDischarge"))
#' mydb[,DateOfAdmission:= as.character(DateOfAdmission)]
#' mydb[,DateOfDischarge:= as.character(DateOfDischarge)]
#'
Expand Down Expand Up @@ -122,7 +123,7 @@ checkBase <- function(base,
stop("Column(s) ", paste(notfound, collapse = ", "), " provided as argument were not found in the database.")
}
# Set column names to default
setnames(report$base,
data.table::setnames(report$base,
old = c(subjectID, facilityID, admDate, disDate),
new = c("sID", "fID", "Adate", "Ddate"))

Expand Down Expand Up @@ -455,15 +456,15 @@ adjust_overlapping_stays = function(report,
probBase[Nprob,..extraCols])
b=b[(b[, Adate] < b[, Ddate]),]
probBase=rbind(a,b,c,d)
setnames(probBase,c("sID","fID","Adate","Ddate",extraCols)) #might not be needed here
data.table::setnames(probBase,c("sID","fID","Adate","Ddate",extraCols)) #might not be needed here
}else{
a=data.table(sID=probBase[-Nprob][(C1&C2), sID],fID=probBase[-Nprob][(C1&C2), fID],Adate=probBase[-Nprob][(C1&C2), Adate],Ddate=probBase[-1][(C1&C2), Adate])
b=data.table(sID=probBase[-Nprob][(C1&C2), sID],fID=probBase[-Nprob][(C1&C2), fID],Adate=probBase[-1][(C1&C2), Ddate],Ddate=probBase[-Nprob][(C1&C2), Ddate])
c=data.table(sID=probBase[-Nprob][!(C1&C2), sID],fID=probBase[-Nprob][!(C1&C2), fID],Adate=probBase[-Nprob][!(C1&C2), Adate],Ddate=probBase[-Nprob][!(C1&C2), Ddate])
d=data.table(sID=probBase[Nprob, sID],fID=probBase[Nprob, fID],Adate=probBase[Nprob, Adate],Ddate=probBase[Nprob, Ddate])
b=b[(b[, Adate] < b[, Ddate]),]
probBase=rbind(a,b,c,d)
setnames(probBase,c("sID","fID","Adate","Ddate")) #might not be needed here
data.table::setnames(probBase,c("sID","fID","Adate","Ddate")) #might not be needed here
}
if (verbose) message("Combining and sorting")

Expand Down
6 changes: 3 additions & 3 deletions R/DataSummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ per_facility_summary <- function(base,
losPerHosp <- (base[, .(mean(difftime(Ddate, Adate, units = "days"))), by = fID])
# losPerHosp<-as.numeric(losPerHosp,units="days")

setnames(losPerHosp, c("node", "LOS"))
data.table::setnames(losPerHosp, c("node", "LOS"))
data.table::setkey(losPerHosp, node)

subjectsPerHosp <- base[, uniqueN(.SD), .SDcols = "sID", by = fID]
setnames(subjectsPerHosp, c("node", "subjects"))
data.table::setnames(subjectsPerHosp, c("node", "subjects"))
data.table::setkey(subjectsPerHosp, node)

admissionsPerHosp <- (base[, .N, by = fID])
setnames(admissionsPerHosp, c("node", "admissions"))
data.table::setnames(admissionsPerHosp, c("node", "admissions"))
data.table::setkey(admissionsPerHosp, node)

sumStats <- Reduce(
Expand Down
2 changes: 1 addition & 1 deletion R/HospiNet.R
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ HospiNet <- R6::R6Class("HospiNet",
private$.hist_degrees <- merge(private$.hist_degrees, d_t, by.x = "degree", by.y = "degree_total", all.x = TRUE)
private$.hist_degrees <- merge(private$.hist_degrees, d_i, by.x = "degree", by.y = "degree_in", all.x = TRUE)
private$.hist_degrees <- merge(private$.hist_degrees, d_o, by.x = "degree", by.y = "degree_out", all.x = TRUE)
setnames(private$.hist_degrees, 2:4, c("total_degree", "in_degree", "out_degree"))
data.table::setnames(private$.hist_degrees, 2:4, c("total_degree", "in_degree", "out_degree"))
private$.hist_degrees
} else {
stop("`$hist_degrees` is read only", call. = FALSE)
Expand Down
15 changes: 15 additions & 0 deletions R/HospitalNetwork-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom data.table :=
#' @importFrom data.table .BY
#' @importFrom data.table .EACHI
#' @importFrom data.table .GRP
#' @importFrom data.table .I
#' @importFrom data.table .N
#' @importFrom data.table .NGRP
#' @importFrom data.table .SD
#' @importFrom data.table data.table
## usethis namespace: end
NULL
4 changes: 2 additions & 2 deletions R/NetworkBuilding.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ matrix_from_edgelist <- function(edgelist,
edgelist <- edgelist[, .N, by = c(origin_name, target_name)] # group identical couples
}
if (!format_long) {
setnames(edgelist, old = count, new = "N")
data.table::setnames(edgelist, old = count, new = "N")
}
setnames(edgelist,
data.table::setnames(edgelist,
old = c(origin_name, target_name),
new = c("origin", "target")
)
Expand Down
2 changes: 1 addition & 1 deletion inst/app/mod_database.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod_database_server <- function(input, output, session, base)
byfacil = reactive({
tmp = HospitalNetwork::per_facility_summary(base())
tmp[, LOS := as.difftime(tim = round(LOS, digits = 2), units = "days")]
setnames(tmp,
data.table::setnames(tmp,
old = c("node", "LOS", "admissions", "subjects"),
new = c("Facility ID", "Mean LOS", "Total number of admissions", "Distinct subjects admitted")
)
Expand Down
30 changes: 30 additions & 0 deletions man/HospitalNetwork-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/checkBase.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-adjust_overlaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ baseCorrDis[, `:=`(adm = as.Date(adm),
dis = as.Date(dis))]
setkey(baseCorrDis, sID, adm)

setnames(baseCorrDis, c("adm", "dis"), c("Adate", "Ddate"))
setnames(baseOver, c("adm", "dis"), c("Adate", "Ddate"))
setnames(baseCorrAdm, c("adm", "dis"), c("Adate", "Ddate"))
data.table::setnames(baseCorrDis, c("adm", "dis"), c("Adate", "Ddate"))
data.table::setnames(baseOver, c("adm", "dis"), c("Adate", "Ddate"))
data.table::setnames(baseCorrAdm, c("adm", "dis"), c("Adate", "Ddate"))

#=== TESTS ==========================================================
report = list()
Expand Down