[Rd] bug in utils:::format.person

Kurt Hornik Kurt@Horn|k @end|ng |rom wu@@c@@t
Mon Jun 5 19:02:32 CEST 2023


>>>>> Achim Zeileis writes:

Thanks---Ivan's fix committed now with c84497.

Best
-k

> Apologies, I missed Ivan's fix to the problem (my day was too long...) 
> which is, of course, better than mine.

> On Sat, 3 Jun 2023, Achim Zeileis wrote:

>> Thierry,
>> 
>> thanks for this, this is a bug in utils:::.format_person_as_R_code(). This 
>> calls deparse() on the elements of the person object with the default 
>> width.cutoff = 60. As your comment exceeds this width, the erroneous 
>> formatting is produced. The simplest reproducible example I could come up 
>> with was:
>> 
>> p <- person(".", comment = c(foo = ".....................",
>> bar = "....................."))
>> writeLines(format(p, style = "R"))
>> 
>> This can be fixed in line 1017 of utils/R/citation.R either by increasing the 
>> width.cutoff, e.g.,
>> 
>> sprintf("%s = %s", names(e), sapply(e, deparse, width.cutoff = 500L))
>> 
>> but, of course, this still has an arbitrary cutoff. So maybe better
>> 
>> sprintf("%s = %s", names(e), sapply(e,
>> function(x) paste(deparse(x), collapse = "")))
>> 
>> which should work.
>> 
>> I'll ping Kurt about this and try to coordinate a fix.
>> 
>> Best wishes,
>> Achim
>> 
>> 
>> On Fri, 2 Jun 2023, Thierry Onkelinx via R-devel wrote:
>> 
>>> Dear all,
>>> 
>>> I think I found a bug in utils::format.person when using style = "R" with a
>>> vector of comments. The comment section is not parsed properly. Please find
>>> below the mwe and the session info.
>>> 
>>> Best regards,
>>> 
>>> Thierry
>>> 
>>> maintainer <- person(
>>> given = "Thierry", family = "Onkelinx", role = c("aut", "cre"),
>>> email = "thierry.onkelinx using inbo.be",
>>> comment = c(
>>> ORCID = "0000-0001-8804-4216",
>>> affiliation = "Research Institute for Nature and Forest (INBO)"
>>> )
>>> )
>>> format(maintainer, style = "R") |>
>>> cat(sep = "\n")
>>> # output
>>> person(given = "Thierry",
>>> family = "Onkelinx",
>>> role = c("aut", "cre"),
>>> email = "thierry.onkelinx using inbo.be",
>>> comment = c("c(ORCID = \"0000-0001-8804-4216\", affiliation =
>>> \"Research Institute for Nature and Forest (INBO)\"", ")"))
>>> 
>>> ─ Session info
>>> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>>> setting  value
>>> version  R version 4.3.0 (2023-04-21)
>>> os       Ubuntu 22.04.2 LTS
>>> system   x86_64, linux-gnu
>>> ui       X11
>>> language nl_BE:nl
>>> collate  nl_BE.UTF-8
>>> ctype    nl_BE.UTF-8
>>> tz       Europe/Brussels
>>> date     2023-06-02
>>> pandoc   NA
>>> 
>>> ─ Packages
>>> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>>> package     * version date (UTC) lib source
>>> cli           3.6.1   2023-03-23 [1] CRAN (R 4.3.0)
>>> fortunes      1.5-4   2016-12-29 [1] CRAN (R 4.3.0)
>>> sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
>>> 
>>> 
>>> 
>>> ir. Thierry Onkelinx
>>> Statisticus / Statistician
>>> 
>>> Vlaamse Overheid / Government of Flanders
>>> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
>>> FOREST
>>> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
>>> thierry.onkelinx using inbo.be
>>> Havenlaan 88 bus 73, 1000 Brussel
>>> www.inbo.be
>>> 
>>> ///////////////////////////////////////////////////////////////////////////////////////////
>>> To call in the statistician after the experiment is done may be no more
>>> than asking him to perform a post-mortem examination: he may be able to say
>>> what the experiment died of. ~ Sir Ronald Aylmer Fisher
>>> The plural of anecdote is not data. ~ Roger Brinner
>>> The combination of some data and an aching desire for an answer does not
>>> ensure that a reasonable answer can be extracted from a given body of data.
>>> ~ John Tukey
>>> ///////////////////////////////////////////////////////////////////////////////////////////
>>> 
>>> <https://www.inbo.be>
>>> 
>>> [[alternative HTML version deleted]]
>>> 
>>> ______________________________________________
>>> R-devel using r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> ______________________________________________
>> R-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list