emr_track.import {naryn}R Documentation

Imports a track from a file or data-frame

Description

Imports a track from a file or data-frame.

Usage

emr_track.import(
  track,
  space,
  categorical,
  src,
  override = FALSE,
  remove_unknown = FALSE
)

Arguments

track

the name of the newly created track

space

db dir string (path), one of the paths supplied in emr_db.connect

categorical

if 'TRUE' track is marked as categorical

src

file name or data-frame containing the track records

override

Boolean indicating whether the creation intends to override an existing track (default FALSE)

remove_unknown

if 'TRUE', removes unknown ids (ids that are not present at 'patients.dob' track) from the data. Otherwise, an error is thrown.

Details

This function creates a new track from a text file or a data-frame. The location of the track is controlled via 'space' parameter which can be any of the db_dirs supplied in emr_db.connect.

If 'src' is a file name, the latter must be constituted of four columns separated by spaces or 'TAB' characters: ID, time, reference and value. The file might contain lines of comments which should start with a '#' character.

Alternatively 'src' can be an ID-Time Values table, which is a data frame with the following columns: "id" "time" "ref" and "value". Note that the file should not contain a header.

(see "User Manual" for more info).

Value

None.

See Also

emr_track.addto, emr_track.create, emr_track.readonly, emr_db.init, emr_track.ls

Examples

emr_db.init_examples()

# import from data frame
emr_track.import(
    "new_track",
    categorical = TRUE,
    src = data.frame(id = c(5, 10), time = c(1, 2), value = c(10, 20))
)

# import from file
fn <- tempfile()
write.table(
    data.frame(id = c(5, 10), time = c(1, 2), reference = c(1, 1), value = c(10, 20)),
    file = fn, sep = "\t", row.names = FALSE, col.names = FALSE
)
emr_track.import("new_track1", categorical = TRUE, src = fn)

# create an empty track
emr_track.import(
    "empty_track",
    categorical = TRUE,
    src = data.frame(id = numeric(), time = numeric(), value = numeric())
)


[Package naryn version 2.6.26 Index]