rjournal / rjtools Goto Github PK
View Code? Open in Web Editor NEWTools for AUTHORS to use for checking and submitting articles to the R Journal
Home Page: https://rjournal.github.io/rjtools/
License: Other
Tools for AUTHORS to use for checking and submitting articles to the R Journal
Home Page: https://rjournal.github.io/rjtools/
License: Other
\code{}
works for pdf output, but not for HTML output.
I'm using rjtools_1.0.0
The check to find the introduction section looks for introduction in all lowercase. If the section is simply called "Introduction", or begins with the word "Introduction", the test will report that the introduction section is missing.
Needed for generating accurate DOIs
Dear programmer,
When executing the command rjtools::create_article(file_name), and then knitting the document, the pdf's name is file_name.pdf and not RJwrapper.pdf, yielding an issue when executing command initial_check_article(path = here::here("rjarticle")). Is it the expected behavior? Should we create, addtionally to file_name.pdf, a copy of this document named RJwrapper.pdf?
Sincerely yours,
The following operators defined in the style add-in file "RJournal.sty", defined as such:
`\renewcommand{\P}{% \mathop{\operator@font I\hspace{-1.5pt}P\hspace{.13pt}}}
\newcommand{\E}{% \mathop{\operator@font I\hspace{-1.5pt}E\hspace{.13pt}}}
\newcommand{\VAR}{\operatorname{var}}
\newcommand{\COV}{\operatorname{cov}}
\newcommand{\COR}{\operatorname{cor}}
`
returns the expected result with the pdf output while not being properly defined with the HTML ouput, as illustrated below in the panel of two figures:
Should we then work around the problem by defining our own operators? For instance, consider the following Rmd defined operator of the covariance:
$\operatorname{var}(x)$
which actually returns the expected result in both HTML and pdf outputs:
I really like the look of the HTML papers. However, I have a problem with the equations and have not found a good solution.
I have following chunk of code:
\begin{equation}
STP_{\textit{parity loss}} = \Big | \ln \Big( \frac{STP_b}{STP_a} \Big)\Big|.
\end{equation}
This notation is very helpful because it allows to accumulate $STP_{\textit{parity loss}}$ overall unprivileged subgroups, so not only in the binary case.
\begin{equation}
STP_{\textit{parity loss}} = \sum_{i \in \{a, b, ...\}} \Big|\ln \Big(\frac{STP_i}{STP_a} \Big)\Big|.
\label{eq:parityLoss}
(\#eq:parityLoss)
\end{equation}
Equation \@ref(eq:parityLoss)
I would like to refer to the second equation. In LaTeX I use \label{eq:parityLoss}
and in markdown (\#eq:parityLoss)
.
It renders like that in HTML:
and like that in PDF:
One problem is that in markdown some equations are not numbered, so the numbering of equations differs between HTML and PDF.
The second problem is that in PDF the label (#eq : parityLoss)
does not disappear.
I have tried to deal with this by using conditional evaluation of R code chunks, but I have not been able to solve this problem.
Any suggestions are welcome!
I use the parallel
package in a paper. initial_check_article
reports that I didn't use CRANpkg
or BIOpkg
:
ℹ NOTE: 1 package(s) used in the text without CRANpkg or BIOpkg commands: parallel
However, parallel
isn't on CRAN as it is in base.R so I use a plain \pkg
to name the package.
Hi all,
thanks for the very nice package. But I get a strange behaviour that the abstract text is pulled off to the right. See here:
https://cmtso.github.io/RJsandboxweb/sandbox
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.19.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=C LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] palmerpenguins_0.1.0 plotly_4.9.3 ggplot2_3.3.3 latexdiffr_0.1.0.9000 rjtools_0.0.0.9001 pander_0.6.4
[7] stringr_1.4.0 lubridate_1.7.10 cowplot_1.1.1 mgcv_1.8-27 nlme_3.1-137 packrat_0.5.0
[13] changepoint_2.2.2 zoo_1.8-9
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lattice_0.20-38 tidyr_1.1.3 assertthat_0.2.1 digest_0.6.27 utf8_1.2.1 mime_0.10 R6_2.5.0
[9] evaluate_0.14 httr_1.4.1 pillar_1.6.0 rlang_0.4.10 lazyeval_0.2.2 rstudioapi_0.13 data.table_1.14.0 Matrix_1.2-15
[17] rmarkdown_2.7 labeling_0.4.2 splines_3.5.3 htmlwidgets_1.5.3 munsell_0.5.0 hunspell_3.0.1 shiny_1.6.0 compiler_3.5.3
[25] httpuv_1.5.5 xfun_0.22 pkgconfig_2.0.3 htmltools_0.5.1.1 tidyselect_1.1.0 tibble_3.1.1 viridisLite_0.4.0 fansi_0.4.2
[33] crayon_1.4.1 dplyr_1.0.5 withr_2.4.2 later_1.1.0.1 grid_3.5.3 jsonlite_1.7.2 xtable_1.8-4 gtable_0.3.0
[41] lifecycle_1.0.0 DBI_1.1.1 magrittr_2.0.1 scales_1.1.1 cli_2.4.0 stringi_1.5.3 farver_2.1.0 fs_1.3.1
[49] promises_1.2.0.1 ellipsis_0.3.1 generics_0.1.0 vctrs_0.3.7 tools_3.5.3 cranlogs_2.1.1 glue_1.4.2 purrr_0.3.4
[57] crosstalk_1.1.1 fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-0 knitr_1.32
I am using the latex template. As instructed I use example block to write code examples:
\begin{example}
> str(iris)
'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
\end{example}
This reports str, obs, num
als possible misspelled words.
This could be solved by handling example blocks the same way as Schunk blocks. For example replace:
chunk_begin <- which(text_bw == "\\begin{Schunk}")
chunk_end <- which(text_bw == "\\end{Schunk}")
chunk_idx <- unlist(purrr::map2(chunk_begin, chunk_end, ~.x:.y))
select_idx <- !c(1:length(text_bw)) %in% c(chunk_idx)
text_clean <- text_bw[select_idx]
by:
chunk_begin <- which(text_bw == "\\begin{Schunk}")
chunk_end <- which(text_bw == "\\end{Schunk}")
chunk_idx <- unlist(purrr::map2(chunk_begin, chunk_end, ~.x:.y))
example_begin <- which(text_bw == "\\begin{example}")
example_end <- which(text_bw == "\\end{example}")
example_idx <- unlist(purrr::map2(example_begin, example_end, ~.x:.y))
select_idx <- !c(1:length(text_bw)) %in% c(chunk_idx, example_idx)
text_clean <- text_bw[select_idx]
In fig.cap="This is a plot created by **ggplot** and \\textbf{ggplot}."
, **ggplot**
only works for html while \\textbf{ggplot}
only works for pdf
This is Table \@ref(tab:mytable)
| var1 | var2 | Var3 |
|-------|-------|------|
| 1 | 2 | 3 |
| 6 | 5 | 4 |
Table: (\#tab:mytable) The caption of mytable
is properly rendered in html:
but not in pdf:
Similar issue with equations:
In equation \@ref(eq:binom), ...
\begin{equation}
f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} (\#eq:binom) \\
\end{equation}
is properly rendered in html:
The html syntax should work with bookdown::pdf_document2
.
In RJwrapper.tex is provided a \code{R_function} command, that enabled in previous purely Latex styles to emphasize specific R functions. However, it seems that this option has not been adjusted to the new Rmd format, as it's only working for the Latex ouput (the text within code brackets does not even appear in the HTML version).
It seems that enabling the downlit personalization, as suggested by the distill documentation, would be a rather nice evolution to highlight these tiny pieces of code, wouldn't it?
While keeping all the lines from the original RJwrapper.tex, I used to add some extra code lines for specific maths notations (for instance, load cancel package \usepackage{cancel} to cross out terms in equations).
But it seems that knitting the document using RStudio automatically retrieves the original RJwrapper.tex, deleting any additional line of code. Then, where should I put these extra-lines designed to format my paper? In the main Rmd document, or in the RJournal.sty file?
The Rmd file below displays the Section labels as ??
in the output HTML file (shown below) although the hyperlink is correct.
For the PDF output (shown below), it shows the section number in the cross reference but there is no section number.
---
title: "Test article"
date: "2022-11-09"
abstract: >
An abstract of less than 150 words.
draft: true
author:
# see ?rjournal_article for more information
- name: Quietest Quokka
type: package
output:
rjtools::rjournal_web_article:
self_contained: yes
toc: no
bibliography: RJreferences.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
```
# Introduction
Refer to Section \@ref(bg)
# Background {#bg}
Test
```{r}
sessioninfo::session_info()
```
─ Session info ─────────────────────────────────────────────────────
setting value
version R version 4.1.2 (2021-11-01)
os macOS Big Sur 10.16
system x86_64, darwin17.0
ui X11
language (EN)
collate en_AU.UTF-8
ctype en_AU.UTF-8
tz Australia/Melbourne
date 2022-12-12
pandoc 2.19.2 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/ (via rmarkdown)
─ Packages ─────────────────────────────────────────────────────────
package * version date (UTC) lib source
bslib 0.4.1 2022-11-02 [1] CRAN (R 4.1.2)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.0)
cli 3.4.1 2022-09-23 [1] CRAN (R 4.1.2)
cranlogs 2.1.1 2019-04-29 [1] CRAN (R 4.1.0)
digest 0.6.30 2022-10-18 [1] CRAN (R 4.1.2)
distill 1.5 2022-09-07 [1] CRAN (R 4.1.2)
downlit 0.4.2 2022-07-05 [1] CRAN (R 4.1.2)
evaluate 0.18 2022-11-07 [1] CRAN (R 4.1.2)
fansi 1.0.3 2022-03-24 [1] CRAN (R 4.1.2)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0)
fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.0)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.2)
htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.1.2)
httr 1.4.4 2022-08-17 [1] CRAN (R 4.1.2)
hunspell 3.0.2 2022-09-04 [1] CRAN (R 4.1.2)
jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.1.0)
jsonlite 1.8.4 2022-12-06 [1] CRAN (R 4.1.2)
knitr 1.41 2022-11-18 [1] CRAN (R 4.1.2)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.1.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.2)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.1.0)
purrr 0.3.5 2022-10-06 [1] CRAN (R 4.1.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0)
Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.1.2)
rjtools 1.0.9.9000 2022-12-12 [1] Github (rjournal/rjtools@74f6cb0)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.1.2)
rmarkdown 2.18 2022-11-09 [1] CRAN (R 4.1.2)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.1.2)
sass 0.4.4 2022-11-24 [1] CRAN (R 4.1.2)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.0)
stringi 1.7.8 2022-07-11 [1] CRAN (R 4.1.2)
stringr 1.5.0 2022-12-02 [1] CRAN (R 4.1.2)
vctrs 0.5.1 2022-11-16 [1] CRAN (R 4.1.2)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.2)
xfun 0.35 2022-11-16 [1] CRAN (R 4.1.2)
yaml 2.3.6 2022-10-18 [1] CRAN (R 4.1.2)
yesno 0.1.2 2020-07-10 [1] CRAN (R 4.1.0)
[1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
In the rmarkdown, when I use \ctv{}
to refer to CRAN Task View, I find that I can see the resutls in the exported pdf, but these could not be found in the knitted html. Is there a way to fix this?
Replicated codes would be:
\ctv{NaturalLanguageProcessing}
Currently could only be used as:
[CRAN Task View: Natural Language Processing](https://cran.r-project.org/web/views/NaturalLanguageProcessing.html)
Thanks.
Produce a package version document (possibly via {renv}
) for reproducibility of articles.
This version set can be interrogated in checks, and be provided in the appendix of articles.
I am running on Windows 11 with R version 4.2.1 and Rstudio 2022.02.03 Build 492.
My understanding is that when rjtools::create_package() is run, a html and pdf file should be created (two output journal types). When I run create_package() and then navigate to the folder, open the markdown document, and click knit in Rstudio, I obtain the following error and no pdf document is created:
Output created: quokka-bilby.html
Error: <callr_status_error: callr subprocess failed: argument is of length zero>
-->
<callr_remote_error in if (metadata$volume < 14) { ...:
argument is of length zero>
in process 1988
Stack trace:
Process 17112:
x callr subprocess failed: argument is of length zero
Process 1988:
18. (function (input) ...
19. rmarkdown::render(input, output_format = "rjtools::rjournal_pdf_article")
20. output_format$post_processor(front_matter, input, output_file, ...
21. base:::.handleSimpleError(function (e) ...
22. h(simpleError(msg, call))
x argument is of length zero
Warning message:
In output_format$post_knit(front_matter, knit_input, runtime, encoding = "UTF-8") :
A date must be provided for your article. Defaulting to today's date.
Execution halted
Any idea why this occurs?
it would be easier for a user not to have to have the full rj package installed too
Dear maintainers of rjtools,
In the template, I can find the type is "package". What are the other optional types (e.g. "Reviews and Proposals" as stated in author guideline, is it possible)?
Also, I find it hard to knit the file and could not find the possible reason. Can you take a look for me? (The files resides at https://github.com/hope-data-science/RJ_reco)
Thanks.
We tried to convert our "Changes on CRAN" report that is published in every R Journal issue from .tex
to .Rmd
. However, two aspects that we have always used are not yet supported in .Rmd
specifically in HTML output:
subtitle
. For PDF output this was straightforward to add in the LaTeX template, see PR #58. However, for HTML output I was not able to add this because I don't know distill well enough.Let me know if you need further details or I can help in any way. If you can give me some guidance on how to implement these two features, I'm willing to try to implement them and make a PR.
This way one could create an article + project from the RStudio New Project menu.
Is it possible for the .bib file to be named the same as the article name? Then we don't need to ask the authors to change the RJreferences in the YAML.
In the template (https://rjournal.github.io/rjtools/articles/article_template.html), we can learn how to include data tables in rjtools
. Is there a way to include tables as provided in https://dereksonderegger.github.io/570L/15-rmarkdown-tricks.html? Currently, I could not find a way to use other formats in the table (e.g. I might want to include a \CRANpkg{}
or [@]
for reference in the table). How can I make a table like below (the references have links):
Thanks.
I made all functions exported so an author can run any individual check themselves this means that the arguments might need to change to make this easier.
also noticed that the "ERROR: The title is not in title case!" will occur if a title has a package name in all caps so perhaps we just want to make this a warning to check for themselves
I have quote data.table
package in the article, but this could not be showed in the html file (it works fine for latex and exported pdf). It seems there are other similar as well (#29). Is there a way to fix this? Thanks.
In check_wrappers
the package make sure that the two expected RJwrapper files (RJwrapper.tex and RJwrapper.pdf) exist. But when we knit the file, the RJwrapper.pdf would be removed and only filename.pdf exist at last. Is there a way to fix this? Or could we just submit the filename.pdf instead of RJwrapper.pdf?
Thanks.
CRAN release checks as inspiration:
could we put it in the pkg down site for example?
The package name is not always started by a capitial letter, when this happens, the submission check returns an error as below:
! ERROR: The title is not in title case! Suggest title to be changed to:
...
Is there a way to fix this?
Thanks.
Via e.g. usethis::use_github_links()
.
Create some sample papers in the inst folder, so that the check functions can have some example code
This might be a feature request. :-)
We need to construct a pkgdown page.
The RJournal.sty file should probably be copied into the paper directory. It is needed in order to compile the Rmd.
What is the equivalent for \code{}
in latex in rjtools
? Thanks.
I'm having trouble getting sizes right for both html and pdf outputs, and am thinking about how do we reference/link the figure in the text when there are two outputs?
I ran rjtools::initial_check_article("paper")
and got the error copied in the issue title.
I had used rjtools::create_article(filename = "response-commentary")
to create the article, and to render it
rmarkdown::render("paper/response-commentary.Rmd", output_format = "rjtools::rjournal_web_article")
rmarkdown::render("paper/response-commentary.Rmd", output_format = "rjtools::rjournal_pdf_article")
Or maybe some tweaks might prevent some false positives e.g. in the presence of "
in the title.
tools::toTitleCase('Comments on "Bla"')
#> [1] "Comments on \"Bla\""
Created on 2021-10-08 by the reprex package (v2.0.0)
In the author instructions, give some instruction on options for handling large data files
\CRANpkg{spatstat.data} is rendered as no text in the html file.
If I remove the dot, then the package name is correctly rendered in the html file.
\CRANpkg{spatstatdata}
An argument in the front matter to distinguish between "Contributed research articles"
,"News and notes"
and potentially other categories is needed. Currently this is tested based on the directory structure, which is unlikely to be accurate for authors writing new papers.
I used create_article(file_name = "articleName", dir_path = "Article")
to create an article in the "Article" subdirectory.
I was surprised to have an article returned for resubmission when the zip archive I constructed with zip_paper(name = "Article/articleName")
didn't contain the necessary HTML & PDF files. On reinspection, I see that the contents of other subdirectories are also included in this zip: I see
adding: Article/RJwrapper.log (deflated 79%)
adding: Article/RJwrapper.pdf (deflated 25%)
adding: Article/RJwrapper.tex (deflated 44%)
adding: Template/RJwrapper.tex (deflated 55%)
Perhaps zip_paper
also needs a dir_path
parameter? Or if this is the intended behaviour, could a message be displayed to the user advising on what further steps must be taken?
As a workaround, I think it is possible to go:
setwd("Article")
zip_paper("articleName")
Then I see
adding: articleName.bib (deflated 70%)
adding: articleName.html (deflated 75%)
adding: articleName.R (deflated 53%)
adding: articleName.Rmd (deflated 60%)
adding: articleName.tex (deflated 62%)
adding: RJwrapper.log (deflated 77%)
adding: RJwrapper.pdf (deflated 25%)
adding: RJwrapper.tex (deflated 44%)
But this does not include the articleName_files
directory to accompany articleName.html
, meaning that the html page is not viewable (as its default body css style visibility:hidden
is not removed).
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rjtools_1.0.0
the paper-with-errors folder has a sample-article set of files, for providing examples for the check functions. to avoid confusion with the actual sample-article these should be renamed paper-with-errors, and the check functions need to have the name of file loaded changed to use this one
also make sure the package version is updated with the change.
now that the package is publicly visibly, and people are testing it out, we need to do version updates with each code change
Hi, I seem to have trouble knitting the r journal article template quokka-bilby.Rmd
to pdf. The steps I use to knit are:
rjtools::create_article()
to create a blank templatermarkdown::render("rjarticle/quokka-bilby.Rmd")
without modifying the template at allThe result is that the HTML document is created, but then the PDF gives error:
Output created: quokka-bilby.html
Error: callr subprocess failed: argument is of length zero
Type .Last.error.trace to see where the error occurred
Typing .Last.error.trace
gives:
r$> .Last.error.trace
Stack trace:
Process 93847:
1. rmarkdown::render("rjarticle/quokka-bilby.Rmd")
2. output_format$on_exit()
3. rjtools:::overlay()
4. callr::r(function(input) { ...
5. callr:::get_result(output = out, options)
6. throw(newerr, parent = remerr[[2]])
x callr subprocess failed: argument is of length zero
Process 94024:
18. (function (input) ...
19. rmarkdown::render(input, output_format = "rjtools::rjournal_pdf_article")
20. output_format$post_processor(front_matter, input, output_file, ...
21. base:::.handleSimpleError(function (e) ...
22. h(simpleError(msg, call))
x argument is of length zero
Some more information:
tinytex::install_tinytex()
, and can knit other documents using the pdf_document
format.Any help would be much appreciated.
Thanks,
Casper
This way the installation instructions would not necessarily need remotes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.