vertesy / ggExpress

ggExpress is the fastest way to create, annotate and and save plots in R.
https://vertesy.github.io/ggExpress
GNU General Public License v3.0
4 stars 2 forks source link

Error in qbarplot : attempt to apply non-function #17

Closed vertesy closed 2 years ago

vertesy commented 2 years ago

Error in qbarplot, inside if (mdlink & save) qMarkdownImageLink(fname)

NOT LOGGED: Log path and filename is not defined in path_of_report
Error in (MarkdownHelpers::llogit())(paste0("![", file_name, "]", "(",  : 
  attempt to apply non-function
vertesy commented 2 years ago

Error is inside

  1. qBarplot →
  2. qMarkdownImageLink →
  3. llogit →
  4. ww.variable.and.path.exists()

llogit <- function(...) {
  argument_list <- c(...)
  LogEntry = paste(argument_list, collapse = " ")
  LogEntry = gsub("^ +| +$", "", LogEntry)
  print(333)
  if (ww.variable.and.path.exists(path_of_report,
                                  alt.message = "NOT LOGGED: Log path and filename is not defined in path_of_report.")) {
    print("JAJAJAJA")
    write(Stringendo::kollapse("\n", LogEntry, print = FALSE),
          path_of_report,
          append = TRUE)
  } else{
    print("ALLES OK")
  }
}

ww.variable.and.path.exists <- function (path = path_of_report, alt.message = NULL) 
{
  Variable.Name = substitute(path)

    print(222)
  if (exists(as.character(Variable.Name))) {
    dn = dirname(path)
    ExisingDir = (dn != "." & dir.exists(dn))
    if (ExisingDir) {
      TRUE
    } else {
      cat("Variable", Variable.Name, " points to a non-existent directory: ", path)
      FALSE
    }
  } else {
    if (is.null(alt.message)) {
      Stringendo::iprint("Variable", Variable.Name, "does not exist.")
    }
    else {
      cat(alt.message)
    }
    FALSE
  }
}
vertesy commented 2 years ago
  1. path_of_report="asa/a" → works
  2. path_of_report="~/GitHub/Projects" → FAILS
  3. rm(path_of_report) → works
vertesy commented 2 years ago

Error was supposedly in:

qMarkdownImageLink <- function(file_name = 'myplot.pdf') {
  llogit(paste0("![", file_name, "]", "(", file_name, ")", collapse = ''))
}