diff options
Diffstat (limited to 'R/drdata.R')
-rw-r--r-- | R/drdata.R | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -1,9 +1,10 @@ drdata <- function(substances, experimentator = "%", db = "cytotox", - celltype="IPC-81",enzymetype="AChE", - organism="Vibrio fischeri",endpoint="Luminescence",whereClause="1", - ok="'ok','no fit'") + celltype = "IPC-81", enzymetype = "AChE", + organism = "Vibrio fischeri", endpoint = "Luminescence", whereClause = "1", + ok = "'ok','no fit'") { - channel <- odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower") + if (requireNamespace("RODBC")) { + channel <- RODBC::odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower") slist <- paste(substances,collapse="','") if (db == "cytotox") { responsetype <- "viability" @@ -29,10 +30,13 @@ drdata <- function(substances, experimentator = "%", db = "cytotox", whereClause," AND ok in (", ok,")",sep="") if (db == "ecotox") query <- paste(query," AND type LIKE '",endpoint,"'",sep="") - data <- sqlQuery(channel,query) - odbcClose(channel) + data <- RODBC::sqlQuery(channel,query) + RODBC::odbcClose(channel) names(data)[[1]] <- "dose" names(data)[[2]] <- "response" data$substance <- factor(data$substance,levels=substances) return(data) + } else { + stop("For this function, the RODBC package has to be installed and configured.") + } } |