R/exportSynonyms.R

Defines functions exportSynonyms

Documented in exportSynonyms

exportSynonyms <- function(file){
	syn <- IgetSynonyms(getOption("odm.handler"))
	export.df <- data.frame()
	for(theTab in unique(syn$tab)){
		sel <- syn$tab == theTab
		sel.id <- syn[sel,2]
		db.entry <- getMetadata(table=theTab, EXACT=TRUE, ID=sel.id)
		if(theTab == "QualityControlLevel"){
			db.column <- which(tolower(names(db.entry)) %in% c("code"))

		} else {
			db.column <- which(tolower(names(db.entry)) %in% c("name", "term", "description", "title"))
		}
		stopifnot(length(db.column)==1)
		export.df <- rbind(export.df, data.frame(phrase=syn[sel,1], table=syn[sel,3], key=db.entry[,db.column]))
	}
	write.table(export.df, file=file, row.names=FALSE)
}

Try the RObsDat package in your browser

Any scripts or data that you put into this service are public.

RObsDat documentation built on May 29, 2017, 12:07 p.m.