Sweave not displaying load message

153 views Asked by At

There is a related question asking the oppostite question, being how to suppress the load message for a package in Sweave. I am trying to display the message and I cannot get it to show when compiling the pdf.

A partial message shows up with using knitr, but it only shows the first two lines and I do not like the general output so I am going to stick with Sweave.

Here is the code chunk:

<<results=verbatim, echo=TRUE, eval=TRUE>>=
library(tcpl)
@

Here is the onLoad function for the package (the function utilizes the packageStartupMessage function to print the message):

.onLoad <- function(libname, pkgname) {

  pkgd <- system.file(package = "tcpl")
  conf_file <- file.path(pkgd, "TCPL.config")

  if (file.exists(conf_file)) {

    source(conf_file, local = TRUE)

  } else {

    cat("## This file will be sourced every time the package is loaded.",
        "## When the package is installed this file is created with",
        "## the default settings for the example databases. You can change",
        "## the behavior for a single session using the 'setTcplOpts'", 
        "## function, or you can change the default load behavior using this",
        "## file. The file will not get overwritten unless the packge is re-",
        "## installed. You can also check the current settings using the",
        "## 'listTcplOpts' function. You can regenerate the default configure",
        "## file by deleting the TCPL.config file in the tcpl package",
        "## directory and reloading the package.",
        "",
        "######## Alter these values to change the default behavior ########",
        "",
        "DRVR = \"SQLite\" # the database (db) driver, 'SQLite' or 'MySQL'",
        "HOST = NA_character_ # the db server",
        "USER = NA_character_ # the db username",
        "PASS = NA_character_ # the db password for the given username",
        "DATA = file.path(pkgd, \"sql\", \"xmpl.sqlite\") # data db name",
        "CHEM = file.path(pkgd, \"sql\", \"xmpl.sqlite\") # chem db name",
        "LOG  = pkgd # filepath to write the run log into, default to pkg dir",
        "",
        "###################################################################",
        "",
        "",
        "tcplSetOpts(DRVR, USER, PASS, HOST, DATA, CHEM, LOG)",
        sep = "\n",
        file = conf_file)

    source(conf_file, local = TRUE)

  }

  v <- tcplListOpts()
  p <- names(v)
  pn <- sapply(p, nchar)
  sep <- sapply(pn, function(x) paste(rep(" ", 11 - x), collapse = ""))
  sep <- paste0(":", sep)
  cs <- sapply(seq_along(v), function(x) paste(p[x], v[[x]], sep = sep[x]))

  packageStartupMessage("tcpl loaded with the following settings:\n  ",
                        paste(cs, collapse = "\n  "),
                        "\nDefault settings stored in TCPL.conf. See ", 
                        "?tcplListOpts or ?tcplSetOpts for more information.")

}

I have tried every combination of code chunk settings I can think of to display the load message, and it will not print to the pdf. I can see it print the message out in the console when the file is being weaved.

EDIT

The same problem holds true for the current release of the data.table package.

<<results=verbatim, echo=TRUE, eval=TRUE>>=
library(data.table)
@

Does not show the printed message in the pdf, but does in a clean console:

library(data.table)
# data.table 1.9.4  For help type: ?data.table
# *** NB: by=.EACHI is now explicit. See README to restore previous behaviour.
0

There are 0 answers