View source: R/respeciate_generic.R
respeciate_generic | R Documentation |
Some samples within SGSS are submitted by laboratories as "GENUS SP" or "GENUS UNNAMED". However, they may also have a fully identified sample taken from the same site within a recent time period. This function captures species_col from another sample within X-days of an unspeciated isolate.
respeciate_generic( x, group_vars, species_col, date_col, window = c(0:Inf), .forceCopy = FALSE )
x |
a data.frame or data.table object |
group_vars |
the minimum grouping set of variables for like samples in a character vector; suggest c('patient_id','specimen_type','genus') |
species_col |
a character containing the column with the organism species_col name |
date_col |
a character containing the column with the specimen/sample date_col |
window |
an integer representing the number of days for which you will allow a sample to be respeciated |
.forceCopy |
default FALSE; TRUE will force data.table to take a copy instead of editing the data without reference |
a data.table with a recharacterised species_col
column
df <- data.frame( ptid = c(round(runif(25,1,5))), spec = sample(c("KLEBSIELLA SP", "KLEBSIELLA UNNAMED", "KLEBSIELLA PNEUMONIAE", "KLEBEIELLA OXYTOCA"), 25,replace = TRUE), type = "BLOOD", specdate = sample(seq.Date(Sys.Date()-21,Sys.Date(),"day"),25,replace = TRUE) ) respeciate_generic(x=df, group_vars=c('ptid','type'), species_col='spec', date_col='specdate', window = 14)[]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.