Skip to content

Commit

Permalink
estimates(): first attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 20, 2023
1 parent d74d94e commit df779e2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions R/estimates.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
estimates_dictionary_build <- function() {
text <-
'Model,Description,Package,Function
lm,Linear Model, stats,lm
logit,Logistic Regression,stats,glm
probit,Probit Regression,stats,glm
ologit,Ordered Logistic Regression,MASS,polr
oprobit,Ordered Probit Regression,MASS,polr
multinom,Multinomial Log-Linear,nnet,multinom'
out <- utils::read.csv(
text = text,
colClasses = c("character", "character", "character", "character"))
colnames(out) <- gsub("\\.$", "", colnames(out))
for (i in 1:4) {
out[[i]] <- trimws(out[[i]])
}
class(out) <- c("estimates_dictionary", "data.frame")
return(out)
}


#' estimates dictionary
#'
#' @noRd
estimates_dictionary <- estimates_dictionary_build()


print.estimates_dictionary <- function(x, ...) {
flag <- insight::check_if_installed("knitr", quietly = TRUE)
if (isTRUE(flag)) {
print(knitr::kable(x))
} else {
print(x)
}
}


estimates <- function(formula, data, model, ...) {
if (missing(model)) {
return(estimates_dictionary)
} else {
checkmate::assert_choice(model, estimates_dictionary$Model)
}
if (missing(formula)) {
fun <- subset(estimates_dictionary, Model == model)
fun <- sprintf("%s::%s", fun$Package, fun$Function)
args <- names(as.list(args(eval(substitute(fun)))))
msg <- pi
insight::format_error(msg)

if (missing(data) || !isTRUE(checkmate::check_data_frame(data, null.ok = FALSE))) {
insight::format_error("blah blah")
}
}

0 comments on commit df779e2

Please sign in to comment.