| testdoseconvert | R Documentation | 
Calls doseconvert on each individual dose string, to
extract structured information such as quantity, frequency and units.
testdoseconvert(text = goldstandard$text, textid = NULL,
    simplify = TRUE, singlewords = NULL, multiwords = NULL,
    patterns = NULL, maxifchoice = TRUE, usebuiltinlookups = FALSE,
    customlookups = NULL, cores = 1,
    noisy = ifelse(length(text) == 1, TRUE, FALSE),
    goldstandard = NULL)
text | 
 Dosage strings to be interpreted.  | 
textid | 
 Optional vector of text or numeric identifiers for the dosage strings.  | 
simplify | 
 FALSE if multiple periods with different doses should be returned as separate doses; TRUE if they should be combined into a single dose (default), thus returning one row per original dosage text.  | 
singlewords | 
 A   | 
multiwords | 
 A   | 
patterns | 
 A   | 
maxifchoice | 
 Whether to return the maximum dose if there is a choice of dose (e.g. 1 or 2 tablets daily). If FALSE, the average is returned.  | 
usebuiltinlookups | 
 Whether to use the lookup table of exact dose strings and their conversion included in the package.  | 
customlookups | 
 A   | 
cores | 
 Number of cores to use, for multiprocessor machines running R on Linux. The 'parallel' package must be loaded in order to use more than one core.  | 
noisy | 
 TRUE or FALSE - whether to display each text and the results of interpretation to the console. By default, noisy = TRUE if only one text is being analysed.  | 
goldstandard | 
 A data.frame or data.table containing textid and interpreted results (i.e. in the same format as the output) against which the results can be compared. This should have the following columns: words (optional), qty, units, freq, tot, max, time, change, choice, duration, daily_dose  | 
This function can be used to test the interpretation of a single text, or test a number of texts against a gold standard interpretation.
Data.table with the following columns:
textid | 
 text identifier  | 
order | 
 if   | 
outcome | 
 outcome of comparison with gold standard; factor with 3 levels: 'actual', 'intended' or 'correct'. If there is no gold standard, all rows have the outcome 'actual'. If there is a goldstandard and the interpretation is correct, the outcome is 'correct', otherwise there are 2 or rows of output, one with outcome 'actual' and the other 'intended'.  | 
qty | 
 numeric; dose quantity  | 
units | 
 character; dose units  | 
freq | 
 numeric; dose frequency per time period  | 
tot | 
 numeric; total dose per time period  | 
max | 
 factor with 3 levels: max, average, exact  | 
time | 
 numeric; time interval in number of days  | 
change | 
 factor with 4 levels: first, second, nochange, combined.
If doses for different time periods combined using   | 
choice | 
 factor with 3 levels: choice, asneeded, nochoice  | 
duration | 
 numeric; duration of prescription  | 
daily_dose | 
 numeric; calculated daily dose  | 
Converted from the original Visual Basic algorithm. Used as part of the testing process for this package.
Anoop Shah
Shah AD, Martinez C. An algorithm to derive a numerical daily dose from unstructured text dosage instructions. Pharmacoepidemiol Drug Saf 2006; 15(3): 161-166. doi: 10.1002/pds.1151 http://onlinelibrary.wiley.com/doi/10.1002/pds.1151/
interpret, doseconvert
data(testset)
results <- as.data.table(testdoseconvert(
    testset$text, goldstandard = testset, noisy = FALSE))
if (all(results$outcome == 'correct')){
    cat('\nAll correct.')
} else {
    cat('\nErrors in analysis:\n')
    print(results[(outcome == 'intended' | outcome == 'actual')][
        order(textid, order, outcome)])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.