[R-pkg-devel] Private S3 Method not Found
Richard M. Heiberger
rmh @end|ng |rom temp|e@edu
Mon Feb 17 19:21:30 CET 2020
latex() probably stopped midway through the compilation because you are
using intermediate routines other than the default.
For pdflatex, for example, you need to run
options(latexcmd='pdflatex', dviExtension='pdf', xdvicmd='open')
before using the latex() function. See the Details section of ?latex.
To suppress the compilation, and stop with just the .tex file, use
print.default.
> tmp <- array(1:8, c(2,4), list(1:2,3:6))
> print.default(latex(tmp))
$file
[1] "tmp.tex"
$style
character(0)
attr(,"class")
[1] "latex"
>
The explicit result of the latex() function is a file name of class
"latex". That way the automatic printing
feature of R shows the compiled file for that specific argument (tmp
in the example above).
Again in R terminology, the actual file "tmp.tex" is produced as a
side effect. The tmp.tex file is designed
to be incorporated into your more comprehensive .tex file.
> tmp <- array(1:8, c(2,4), list(1:2,3:6))
> tmp.latex <- latex(tmp)
> print.default(tmp.latex)
$file
[1] "tmp.tex"
$style
character(0)
attr(,"class")
[1] "latex"
There are latex methods for many classes of objects. formula is not
one of them.
>From your short initial description, it looks like what you are doing
could be thought of
as the latex.formula method. I recommend doing it that way to get the
leverage of
all the other things the latex() and related functions do. Once it is
working I suggest you
send your function to Frank Harrell (I cced him on this email) and
request that it be included as part of Hmisc::latex
You, of course, retain authorship
Rich
On Mon, Feb 17, 2020 at 10:54 AM <bill using denney.ws> wrote:
>
> Hi Rich,
>
>
>
> I’m not doing the same thing as Hmisc::latex(). That generates a .tex file and compiles it (or at least it appears to try to do that on my system, but it stopped partway through for me).
>
>
>
> When I ran
>
>
>
> Hmisc::latex(a~b)
>
>
>
> It generated a .tex file for a table:
>
>
>
> \begin{table}[!tbp]
>
> \begin{center}
>
> \begin{tabular}{l}
>
> \hline\hline
>
> \multicolumn{1}{c}{}\tabularnewline
>
> \hline
>
> ~\tabularnewline
>
> a\tabularnewline
>
> b\tabularnewline
>
> \hline
>
> \end{tabular}\end{center}
>
> \end{table}
>
>
>
> While I’m wanting an equation:
>
>
>
> $$a = b$$
>
>
>
> Thanks,
>
>
>
> Bill
>
>
>
> From: Richard M. Heiberger <rmh using temple.edu>
> Sent: Monday, February 17, 2020 10:31 AM
> To: bill using denney.ws
> Cc: r-package-devel using r-project.org
> Subject: Re: [R-pkg-devel] Private S3 Method not Found
>
>
>
> Please be consistent with the latex() function in the Hmisc package. For example, for an array x, latex (x) produces a complete latex table environment. See the ?latex helpfile for details.
>
>
>
> Rich
>
>
>
> On Mon, Feb 17, 2020 at 10:07 <bill using denney.ws> wrote:
>
> Hello,
>
>
>
> I'm working on a function in a package that will provide an exported
> function that will convert formula to LaTeX equations. For that, it
> recursively goes through the formula converting objects of class "formula",
> "call", "name", and "(" to LaTeX.
>
>
>
> I have a private S3 generic function that I'm using for the conversion, but
> for some reason, the generic is not detected, and checking the package fails
> for that reason
> (https://travis-ci.org/billdenney/bsd.report/jobs/651510333):
>
>
>
> no applicable method for 'knit_print_helper_formula' applied to an object of
> class "name"
>
> Backtrace:
>
> 1. testthat::expect_equal(...)
>
> 4. bsd.report:::knit_print.formula(a ~ b(c))
>
> 6. bsd.report:::knit_print_helper_formula.formula(x, ..., replacements =
> replacements)
>
> 9. bsd.report:::knit_print_helper_formula.call(x[[3]], ...)
>
> 10. bsd.report:::knit_print_helper_formula.function_call(x, ...)
>
> 11. base::sapply(...)
>
> 12. base::lapply(X = X, FUN = FUN, ...)
>
> 13. bsd.report:::FUN(X[[i]], ...)
>
>
>
> But, there is a knit_print_helper_formula.name function call defined
> (https://github.com/billdenney/bsd.report/blob/master/R/knit_print.formula.R
> #L60-L79):
>
>
>
> knit_print_helper_formula <- function(x, ...) {
>
> UseMethod("knit_print_helper_formula")
>
> }
>
>
>
> # Some other methods
>
>
>
> knit_print_helper_formula.name <- function(x, ...) {
>
> # Function body
>
> }
>
>
>
> Does anyone know why the S3 method for name class objects is not found when
> checking the package?
>
>
>
> Thanks,
>
>
>
> Bill
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
More information about the R-package-devel
mailing list