Skip to content

Commit

Permalink
updates requested by CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
dicook committed Apr 15, 2024
1 parent 7817168 commit 423f75a
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rjtools
Title: Preparing, Checking, and Submitting Articles to the 'R Journal'
Version: 1.0.12
Version: 1.0.13
Authors@R:
c(person(given = "Mitchell",
family = "O'Hara-Wild",
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rjtools 1.0.13

* fix error reported by CRAN, occurring on linux, related to test code
* Fixes in response to issues #119 and #120
* web site documentation and vignettes updated

# rjtools 1.0.12

* Updates for accessibility based on updates in distill package.
Expand Down
27 changes: 14 additions & 13 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,33 @@ check_folder_structure <- function(path){
r_files <- files[file_exts == "R"]
log_aux <- files[file_exts %in% c("log", "aux", "out")] |> concat()
file_txt <- tools::file_path_sans_ext(files)
motivation <- files[grepl("motivation", file_txt)] |> concat()
motivation <- files[file_exts %in% c("md", "doc", "docx")] |> concat()

valid_exts <- c("Rproj", ".sty", "bib", "Rmd", "html", "R", "tex", "pdf", "")
exts_checked <- c(img_exts, data_exts, "R", "log", "aux")
non_standard <- files[!file_exts %in% c(valid_exts, exts_checked)]
non_standard <- non_standard[!grepl("motivation", non_standard)] |> concat()

if (length(img_files) != 0){
log_error("Image(s) detected in the main directory: {img_files}.
They should be placed in the figures/ folder.")
} else if (length(data_files) != 0){
log_error("Data file(s) detected in the main directory: {data_files}.
They should be placed in the data/ folder.")
non_standard <- non_standard[!grepl("RJournal", non_standard)] |> concat()

if ((length(img_files) > 1) | (str_length(img_files) != 0)){
log_error("It looks like there are image(s) in the main directory: {img_files}.
If so, they should be organised into figures/ folder.")
} else if ((length(data_files) > 1) | (str_length(data_files) != 0)){
log_error("It looks like there are data file(s) in the main directory: {data_files}.
If so, they should be organised into data/ folder.")
} else if (length(r_files) > 1){
r_files <- concat(r_files)
log_error(
"Multiple R files detected: {r_files}.
Should they be organised in the scripts/ folder?
Scripts should be organised in the scripts/ folder.
The master R file generated from rendering should still be in the main directory.")
} else if (length(log_aux) != 0){
} else if (str_length(log_aux) != 0){
log_error("Auxiliary log and aux files detected: {log_aux}.
They should be removed.")
} else if (length(motivation) != 0){
log_error("Motivation letter related files detected: {motivation}.
} else if (str_length(motivation) != 0){
log_error("Possible motivation or cover letters detected in main folder: {motivation}.
They should be placed in the motivation-letter/ folder.")
} else if (length(non_standard) != 0){
} else if ((length(non_standard) > 1) | (str_length(non_standard) != 0)){
log_warning(
"Other non-standard file detected: {non_standard}.
Should they be removed? ")
Expand Down
2 changes: 1 addition & 1 deletion inst/sample-article/article.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Some packages on interactive graphics include \CRANpkg{plotly} [@plotly] that in
The \CRANpkg{palmerpenguins} data [@palmerpenguins] features three penguin species which has a lovely illustration by Alison Horst in Figure \@ref(fig:penguins-alison).

```{r penguins-alison, out.width = "100%", out.height = "30%", fig.cap = "Artwork by \\@allison\\_horst", fig.alt="A picture of three different penguins with their species: Chinstrap, Gentoo, and Adelie. "}
knitr::include_graphics("penguins.png")
knitr::include_graphics("figures/penguins.png")
```

Table `r knitr::asis_output(ifelse(knitr::is_html_output(), '\\@ref(tab:penguins-tab-interactive)', '\\@ref(tab:penguins-tab-static)'))` prints at the first five rows of the `penguins` data:
Expand Down
105 changes: 105 additions & 0 deletions inst/sample-article/data/d.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
x1,y
1.331388810161183,-0.40794465178623796
0.018379849126694738,0.29543118877336383
-6.384658534502307e-5,-0.26140952482819557
0.20097880803736073,-0.3894907310605049
0.44958148917599977,0.368764974642545
1.6813343316910867,0.972025977447629
-0.37157864277577374,0.7114357207901776
0.8658958597679552,-0.676908531691879
-0.07741520828813821,-0.4443690092302859
0.5077534449957314,-0.6342588905245066
1.0402428480643626,-0.991299734916538
1.528754267795163,0.8489523795433342
-0.5133315171444137,0.8596313521265984
1.19187930421443,0.3660597880370915
2.628419386259298,-0.8696116381324828
-0.22575875360198772,0.08188785100355744
0.5265026549970548,0.6975274006836116
-0.30316469007457475,-0.779734761454165
-0.2739911610454293,0.34948889538645744
0.2184605292063523,-0.6812267135828733
-1.7084626427572023,0.7217531879432499
0.4892030894947803,-0.744221992790699
0.1205082618897043,-0.22628485225141048
-0.3838299347473275,0.5288297622464597
-0.07314742215145219,-0.7935552075505257
-0.09368838768562776,0.9291862868703902
1.3162570738241588,-0.5068046585656703
1.4319739160459208,0.6023194268345833
0.6436276108643331,-0.041779174003750086
0.11509520125044838,-0.9598376811482012
-0.32430384553195746,0.571977328043431
0.2468762040830978,0.42122157476842403
-1.3016855617807452,0.0883472478017211
-2.808311149714747,-0.752943629398942
0.22586935498784808,-0.2064671628177166
0.767545881482094,0.042037158738821745
0.9771548380840375,0.43377191154286265
-0.8601814827645871,-0.19376414828002453
0.7920150123221833,-0.9100403627380729
0.08880167191703651,-0.46525690890848637
-0.19070888359489455,0.6059966273605824
-0.9235892240339258,-0.032062700018286705
1.5546771300201603,0.6764600053429604
-0.9808832868961554,0.1458169068209827
-0.027822496416691843,0.11699129268527031
0.9146831480656326,-0.7585837738588452
0.2501284714997089,0.9946243944577873
0.16193267087449797,-0.5401482689194381
-0.7465067027628258,-0.448442991822958
-0.08949871792868296,0.6868227650411427
-1.1129710639360162,-0.8959847427904606
0.3191233063707866,0.48254246916621923
-1.2313638505091624,-0.8556301682256162
1.8255386025536902,-0.4745626151561737
-0.3614525008618072,0.9763105371966958
-0.7787715060066702,0.9138894453644753
-0.1244940841211145,0.8267847467213869
-1.4014107374104585,0.6660974933765829
-2.6155831895889112,-0.9598896154202521
0.40283462349351307,-0.2046024170704186
-0.28952371113930125,0.35141595965251327
-0.2124138282234785,0.2512443671002984
1.5373573208023061,-0.16033220011740923
-0.986607574830872,-0.09320439398288727
1.138560788209093,0.7897717035375535
0.2701231896305656,0.8245334457606077
0.46855781696830057,-0.3013404789380729
0.47499616546879353,0.8359466781839728
0.6716273090553908,0.014085867907851934
-0.3361644655992889,0.27718858141452074
0.43721959902377855,-0.3692989144474268
0.48352372943211164,-0.4534123707562685
1.9147335233797984,-0.39550251280888915
-0.44051758115821865,-0.03464156715199351
1.0086665103966,0.6864634803496301
0.34544197830175893,-0.18724709097296
0.6960106523133969,-0.5213198070414364
0.2996900566683094,-0.6154520749114454
-0.2067074586223824,-0.33009388437494636
-0.580050141374622,0.8658358752727509
-0.15027423105380855,0.5903262919746339
-0.46151679333382245,-0.5033708191476762
0.9492645489442697,0.15409184154123068
0.5555889896058835,-0.5970373908057809
-0.38290387144127763,0.40510260546579957
-0.9232609828388708,0.8341664974577725
0.046624788549521824,-0.7251430391333997
-0.549546392838309,0.018814462702721357
-1.0630012366459207,0.9481020369566977
1.4646634441407695,0.47351425886154175
-0.7977728808729846,0.9034813344478607
0.008614051142740279,0.09282215917482972
-1.6847058795386252,-0.8733479119837284
3.8485383831213484,0.5753998174332082
0.27278184122859506,0.7002016296610236
0.4155558839091867,0.15514136897400022
-0.29456237339048047,-0.7361523164436221
-0.32660466682753336,0.9123321380466223
-1.2747559780903475,0.3909331359900534
-0.13479604199567174,-0.8454501498490572
-2.691769671161283,-0.4930398431606591
-1.1669035511639863,0.056795168202370405
0.8758013295424727,-0.5534305470064282
-0.12247790831938046,-0.7143188542686403
File renamed without changes
File renamed without changes.
2 changes: 2 additions & 0 deletions inst/sample-article/scripts/testing.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is just an example for how scripts should be organised
d <- data.frame(x1=rnorm(104), y=runif(104, -1, 1))
6 changes: 3 additions & 3 deletions tests/testthat/test-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ test_that("unnecessary check works", {
expect_ERROR(check_unnecessary_files(bad_article_path))
})

test_that("spelling check works", {
expect_NOTE(check_spelling(article_path))
})
#test_that("spelling check works", {
# expect_NOTE(check_spelling(article_path))
#})

test_that("proposed package check works", {
expect_SUCCESS(check_proposed_pkg("ggplot2"))
Expand Down
8 changes: 4 additions & 4 deletions vignettes/check_functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ path_to_article <- system.file("paper-with-errors", package = "rjtools")
library(rjtools)
```

The `rjtools` package has implemented some automated checks on style, spelling, and package availability, according to the R Journal format. For a comprehensive instruction on the journal format, we recommend authors to follow [instructions for Authors](https://journal.r-project.org/submissions.html).
The `rjtools` package has implemented some automated checks to assess if it appropriately follows the R Journal format. It is important that authors read information at [journal website](https://journal.r-project.org).

This vignette will demonstrate these checks with an example article, [paper-with-errors](https://github.com/rjournal/rjtools/tree/main/inst/paper-with-errors), where the argument `path = path_to_article` in the checks points to the directory of the .tex file. If you have created the article using `create_article()` with the default arguments, you can check with `path = here::here("rjarticle")`.

Expand Down Expand Up @@ -69,7 +69,7 @@ and they can all be individually checked on the article.
check_filenames(path = path_to_article)
```

The .bib file is named `Rjreferences.bib` when created and we recommend setting a consistent name across the .bib, .tex, and .Rmd file. A fix to this is to rename the `Rjreferences.bib` as the file name you used when create the article, in our case, `paper-with-errors`.
The .bib file is named `Rjreferences.bib` when created and we recommend setting a consistent name across the .bib, .tex, and .Rmd file. A fix to this is to **rename** the `Rjreferences.bib` as the file name you used when create the article, in our case, `paper-with-errors`.

## Presence of unnecessary files

Expand All @@ -85,7 +85,7 @@ This function checks that the folder doesn't contain the `RJtemplate.tex` file,
check_cover_letter(path = path_to_article)
```

Cover letter should be provided for article of type "add-on package" and saved at the same folder as the article. The function checks whether there is a file containing the word "motivation" in its name. Our article passes this check.
Cover letter should be provided for all articles and saved at the same folder as the article. The function checks whether there possible motivation letters are in the main directory, and recommends to put them in the `motivation-letter` folder if so. Our article passes this check.

## Article title is in title case

Expand Down Expand Up @@ -196,7 +196,7 @@ Advice on good coding style can be found in the `rjtools` article ["More details
## Citations

- All R packages used in the work are appropriately cited. For example, if you use `ggplot2` to make your plots, the citation for this package needs to be added to your paper. See more details below if you need help on how ot do this.
- All references need to have a DOI where available.
- All references need to have a DOI where available, best added using the URL item.
- The default bibliography style needs to be used.
- Use consistent capitalization for titles in the citations, which may require manual editing if extracting citation information from different services.

Expand Down
2 changes: 1 addition & 1 deletion vignettes/create_article.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The `rjtools::rjournal_article` output specified in the article YAML will create

## Note: `rticles` template

The `rticles` package historically contained a template for creating an *R Journal* article, which you might have used before if you have been already working with R Markdown for writing papers. This template is now synchronised with the template in `rjtools`.
<!--The `rticles` package historically contained a template for creating an *R Journal* article, which you might have used before if you have been already working with R Markdown for writing papers. This template is now synchronised with the template in `rjtools`.-->

Now feel free to head to the vignette *More details on the R Journal format* for an example article and more detailed information on the template.

Expand Down
4 changes: 2 additions & 2 deletions vignettes/format-details.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If you would like to have an interactive plot in the html output, you will also

Of course, if only a static plot is to be rendered in both outputs, a single code chunk and a single inline reference will be sufficient.

Note that the structure of a thorough caption is three components: (1) what is the plot/table about, (2) specific details of plot/table, like what type of display and how variables are mapped, (3) the most important thing that the reader should learn.
**Note that the structure of a thorough caption is three components: (1) what is the plot/table about, (2) specific details of plot/table, like what type of display and how variables are mapped, (3) the most important thing that the reader should learn.**

## Static

Expand Down Expand Up @@ -88,7 +88,7 @@ For in-text citation, you will something like this:

Figure \@ref(fig:`r "\u0060r"` ifelse(knitr::is_html_output(), 'penguins-interactive', 'penguins-static')`r "\u0060"` shows ...

This line is quite complicated so let's dissect its components: the `ifelse` statement uses `knitr::is_html_output()` to decide if the output is an html or pdf output, then completes the fugure reference to read either `\@ref(fig:penguins-interactive)`, to reference the chunk of the interactive graphic in HTML output, or `\@ref(fig:penguins-static)`, to reference the static figure for PDF output.
This line is quite complicated so let's dissect its components: the `ifelse` statement uses `knitr::is_html_output()` to decide if the output is an html or pdf output, then completes the figure reference to read either `\@ref(fig:penguins-interactive)`, to reference the chunk of the interactive graphic in HTML output, or `\@ref(fig:penguins-static)`, to reference the static figure for PDF output.

## Sizing

Expand Down

0 comments on commit 423f75a

Please sign in to comment.