Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Fix for vector memory allocation error
Browse files Browse the repository at this point in the history
The new anonymised ccRecords were causing R to crash when using create_cctable(). This is because the findMaxTime function was returning the number of hours since 1970 and forcing vector allocation to this amount. This fixes the issue
  • Loading branch information
DocEd committed Jul 27, 2018
1 parent 44903cd commit 4a3904b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ Makefile
.travis.yml
appveyor.yml
paper.md
^.*\.Rproj$
^\.Rproj\.user$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
*.httr-oauth
.Rproj.user
12 changes: 9 additions & 3 deletions R/ccTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,13 @@ getEpisodePeriod <- function (e, unit="hours") {
# The failure of POSIX conversion indicates that this episode is either
# anonymised or has a missing or incorrect value of discharge or admission
# time.
if (is.na(tadm) || is.na(tdisc))
period_length <- findMaxTime(e)
else {
if (is.na(tdisc)) {
period_length <- ceiling(
as.numeric(
difftime(
as.POSIXct.numeric(findMaxTime(e), origin = "1970-01-01 00:00:00"), tadm, units = unit)
))
} else {
if (any(is.null(tdisc), is.null(tadm)))
period_length <- NULL
else
Expand All @@ -466,6 +470,8 @@ getEpisodePeriod <- function (e, unit="hours") {
if (period_length == 0)
period_length <- period_length + 1
}



if (is.null(period_length))
warning("This episode does not have any time series data: ",
Expand Down

1 comment on commit 4a3904b

@docsteveharris
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks OK. I note the automated tests are all failing. Is this related?

Please sign in to comment.