Comments (2)
I found out it's not exactly the same error that happens for the other variables.
for hospitalID, I get:
Error in get(hospitalID) : object '18091301' not found
where 18091301 is a hospital code
for admDate:
Error: invalid first argument
with traceBack:
- stop(err$message, call. = FALSE)
- .checkTypos(e, names(x))
- value[3L]
- tryCatchOne(expr, names, parentenv, handlers[[1L]])
- tryCatchList(expr, classes, parentenv, handlers)
- tryCatch(eval(.massagei(isub), x, parent.frame()), error = function(e) .checkTypos(e,
names(x)))[.data.table
(base, get(admDate) > get(disDate), , which = T) at DataManagement.R#302- base[get(admDate) > get(disDate), , which = T] at DataManagement.R#302
- checkDates(base = checkResults$base, patientID = patientID, hospitalID = hospitalID,
admDate = admDate, disDate = disDate, convertDates = convertDates,
dateFormat = dateFormat, deleteErrors = deleteErrors, verbose = verbose,
...) at DataManagement.R#62- checkBase(countryData, deleteMissing = "patient", deleteErrors = "patient",
convertDates = TRUE, dateFormat = "%y%m%d", patientID = "pID",
hospitalID = "hID", disDate = "dis", admDate = "admDate",
verbose = TRUE, maxIteration = 250)
and for disDate the same with traceBack:
- stop(err$message, call. = FALSE)
- checkTypos(e, names(x))
- value[3L]
- tryCatchOne(expr, names, parentenv, handlers[[1L]])
- tryCatchList(expr, classes, parentenv, handlers)
- tryCatch(eval(.massagei(isub), x, parent.frame()), error = function(e) .checkTypos(e,
names(x)))[.data.table
(base, get(admDate) > get(disDate), , which = T) at DataManagement.R#302- base[get(admDate) > get(disDate), , which = T] at DataManagement.R#302
- checkDates(base = checkResults$base, patientID = patientID, hospitalID = hospitalID,
admDate = admDate, disDate = disDate, convertDates = convertDates,
dateFormat = dateFormat, deleteErrors = deleteErrors, verbose = verbose,
...) at DataManagement.R#62- checkBase(countryData, deleteMissing = "patient", deleteErrors = "patient",
convertDates = TRUE, dateFormat = "%y%m%d", patientID = "pID",
hospitalID = "hID", disDate = "disDate", admDate = "adm",
verbose = TRUE, maxIteration = 250)
from hospitalnetwork.
Hi Tjibbe,
now :
mydb = create_fake_patientDB(n_patients = 100, n_hospital = 5)
mat1 = hospinet_from_patient_database(base = mydb)
and
setnames(mydb, 1:2, c("patientID", "hospitalID"))
mat2 = hospinet_from_patient_database(base = mydb, patientID = "patientID", hospitalID = "hospitalID")
give the same thing.
The problem was that the resolution of the variables in R is done in multiple context, first the current, and if nothing is found, the parent, etc... Hence the issue can be simplified as:
dt = data.table(a = 1:5)
a = "a"
var = "a"
dt[, get(var)] #works as intended
dt[, get(a)] #fails
One option to solve this would be to force resolution in the parent environment by deactivating the resolution within the data.table:
dt[, get(var), with = FALSE]
dt[, get(a), with = FALSE]
or use the shorter version ".." which disable nothing but indicate that the variable needs to be looked in the parent environment (hence not in the data.table)
dt[, ..var]
dt[, ..a]
I've implemented the second option in the last commit.
from hospitalnetwork.
Related Issues (18)
- Unit test scripts
- Checking base during edgelist_from_base() HOT 15
- Complete documentation of functions
- new implementation of overlap management HOT 5
- Summary statistics in HospiNet object are actually computed from the original base HOT 6
- Shiny app HOT 3
- Columns for checking duplicated entries HOT 2
- S3 object HospiNet HOT 10
- FR: function adding GPS coordinates to HospiNet object
- FR: add fake GPS coordinates in fake database generation function
- circular network not working when only one cluster is present in the network
- Hospitals with no transfers get silently dropped HOT 1
- Fake data HOT 4
- Include (flagged) direct transfers in edgelist_from_patient_database
- Features you want to see in the package HOT 7
- a shiny ui frontend to the package
- How overlapping stays are adjusted HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hospitalnetwork.