[R-pkg-devel] debian - how to replicate the error

2022-09-19 Thread Zhang, Xueqiong
Hi,
I am seeking help on error messages from Debian-gcc check  –

  1.  My package passed checks on windows and macos,  but failed on debian-gcc 
with testthat.R error. I don’t have a linux box, and was not able to check it 
via r-hub-linux-platforms since some of bioc dependencies are not installed on 
r-hub. What should I do for the error check, any ideas?
  2.  testthat.R runs pretty well on my macos machine. I am thinking error from 
debian was caused by tempdir()? this is the code of how I created the temp 
folder  fd_out = as.character(paste0(tempdir(), "/", "outputs", "/")) . The 
error will go away if I change the code to fd_out = tempdir() ?
  3.  Also,  tempdir() is something like this 
"/var/folders/_p/vkt5cmsn2559zqnyhpdwnnsrgn/T//RtmpUHe1uR" .  I wonder if 
the double slashes doesn’t recognized by linux?

Thanks,

Joan Zhang

Version: 0.1.2
Check: tests
Result: ERROR
 Running ‘testthat.R’ [157s/277s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
 > library(testthat)
 > library(epitopR)
 >
 > test_check("epitopR")
 [ FAIL 1 | WARN 0 | SKIP 2 | PASS 0 ]

 ══ Skipped tests 
═══
 • empty test (2)

 ══ Failed tests 

 ── Error (test-core_mut.R:10:3): test core_mut 

 

 Error in `select(., -c(id, seq_num))`: Can't subset columns that don't 
exist.
 x Column `id` doesn't exist.



[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Non-ASCII and CRAN Checks

2022-09-19 Thread Neal Fultz
This happened to me this summer when working on the recent US census; came
up with two possible solutions:

1. Re-encode the column to UTF-8. Example:

Encoding(puertoricocounty20$NAME) <- "latin1"
puertoricocounty20$NAME <- iconv(puertoricocounty20$NAME, "latin1", "UTF-8")

2. Use gsub to replace all n-tilde's with regular n's.

- Neal

On Mon, Sep 19, 2022 at 12:53 PM Igor L  wrote:

> Hello everybody,
>
> I'm testing my package with the devtools::check() function and I got a
> warning about found non-ASCII strings.
>
> These characters are in a dataframe and, as they are names of institutions
> used to filter databases, it makes no sense to translate them.
>
> Is there any way to make the check accept these characters?
>
> They are in latin1 encoding.
>
> Thanks in advance!
>
> --
> *Igor Laltuf Marques*
> Economist (UFF)
> Master in urban and regional planning (IPPUR-UFRJ)
> Researcher at ETTERN e CiDMob
> https://igorlaltuf.github.io/
>
> [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Non-ASCII and CRAN Checks

2022-09-19 Thread Igor L
Hello everybody,

I'm testing my package with the devtools::check() function and I got a
warning about found non-ASCII strings.

These characters are in a dataframe and, as they are names of institutions
used to filter databases, it makes no sense to translate them.

Is there any way to make the check accept these characters?

They are in latin1 encoding.

Thanks in advance!

--
*Igor Laltuf Marques*
Economist (UFF)
Master in urban and regional planning (IPPUR-UFRJ)
Researcher at ETTERN e CiDMob
https://igorlaltuf.github.io/

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Read and restore .Random.seed in package

2022-09-19 Thread Jan van der Laan

Thanks!

I noticed that there was an almost identical question asked on this list 
only a few days ago that I completely missed. Sorry for that. Your 
example and the examples there at least give me a better way to write my 
function.


Jan


On 19-09-2022 11:58, Achim Zeileis wrote:

On Mon, 19 Sep 2022, Jan van der Laan wrote:



I have a function in which I need to draw some random numbers. 
However, for some use cases, it is necessary that the same random 
numbers are drawn (when the input is the same) [1]. So I would like to 
do a set.seed in my function. This could, however, mess up the seed 
set by the user. So what I would like to do is store .Random.seed, 
call set.seed, draw my random numbers and restore .Random.seed to its 
original value. For an example see the bottom of the mail.


Am I allowed on CRAN to read and restore .Random.seed in a package 
function? This seems to conflict with the "Packages should not modify 
the global environment (user’s workspace)." policy. Is there another 
way to get the same random numbers each time a function is called 
without messing up the seed set by the user? [2]]


My understanding is that restoring the .Random.seed is exempt from this 
policy. See the first lines in stats:::simulate.lm for how R itself 
deals with this situation:


simulate.lm <- function(object, nsim = 1, seed = NULL, ...)
{
     if(!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE))
     runif(1) # initialize the RNG if necessary
     if(is.null(seed))
     RNGstate <- get(".Random.seed", envir = .GlobalEnv)
     else {
     R.seed <- get(".Random.seed", envir = .GlobalEnv)
 set.seed(seed)
     RNGstate <- structure(seed, kind = as.list(RNGkind()))
     on.exit(assign(".Random.seed", R.seed, envir = .GlobalEnv))
     }

[...]



[1] Records are randomly distributed over cluster nodes. For some use 
cases it is necessary that the same records end up on the same cluster 
nodes when the function is called multiple times.


[2] A possible solution would be to document that the user should 
ensure that the same seed is used when calling this function for the 
use cases where this is needed.



set_seed <- function(seed, ...) {
 if (!exists(".Random.seed")) set.seed(NULL)
 old_seed <- .Random.seed
 if (length(seed) > 1) {
   .Random.seed <<- seed
 } else {
   set.seed(seed, ...)
 }
 invisible(old_seed)
}

foo <- function(n) {
 old_seed <- set_seed(1)
 on.exit(set_seed(old_seed))
 runif(n)
}

Using these:


set.seed(2)
foo(5)

[1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819

runif(5)

[1] 0.1848823 0.7023740 0.5733263 0.1680519 0.9438393

foo(5)

[1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819

runif(5)

[1] 0.9434750 0.1291590 0.8334488 0.4680185 0.5499837

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel




__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Unable to create manual

2022-09-19 Thread Uwe Ligges




On 16.09.2022 20:17, Edward Wei wrote:
That is an interesting thought. I don't think I have downloaded LaTex 
explicitly, however, I do have MikTex and I added that file to PATH 
manually.


This is what my current PATH calls:
"c:/rtools42/x86_64-w64-mingw32.static.posix/bin;c:/rtools42/usr/bin;C:\\Program 
Files\\R\\R-4.2.0\\bin\\x64;C:\\Program Files (x86)\\Common 
Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program 
Files\\Wolfram Research\\WolframScript\\;C:\\Program 
Files\\Git\\cmd;C:\\Users\\edmon\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\edmon\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\edmon\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64\\;C:/Program 
Files/RStudio/bin/quarto/bin"


I have been able to generate a PDF of my package by entering :
tools::texi2pdf(file = "avfintools.Rcheck/avfintools-manual.tex")
on the console.

Is there a way to submit the manual manually rather than have it 
compiled? Or is it a requirement for the manual to be able to be 
compiled from the package?



The latter, but the mechanism works on  CRAN, so you do not ned to worry 
about that.


Best,
Uwe Ligges



Thanks for your help,


On Wed, Sep 14, 2022 at 3:14 PM Uwe Ligges 
> wrote:




On 14.09.2022 23:54, Duncan Murdoch wrote:
 > On 12/09/2022 9:09 a.m., Edward Wei wrote:
 >> This is the following error message I get from R CMD check:
 >>
 >> LaTeX errors when creating PDF version.
 >> This typically indicates Rd problems.
 >> * checking PDF version of manual without index ... ERROR
 >> Re-running with no redirection of stdout/stderr.
 >> Hmm ... looks like a package
 >> Converting parsed Rd's to LaTeX ...
 >> Creating pdf output from LaTeX ...
 >> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
 >> quiet,  :
 >>    pdflatex is not available
 >
 > This looks like a problem in the way tools::texi2dvi detects
pdflatex.
 > If you have a valid LaTeX file, try running
 >
 > tools::texi2dvi(filename, pdf = TRUE)
 >
 > If that gives the same message, then debug(tools::texi2dvi), and
repeat,
 > single stepping through the function to see what test it uses, and
 > figure out why it fails on your system.

Or the env var PATH is overwritten once R get started, perhaps you have
it in one of the files R process it at startup?
Does Sys.getenv("PATH") show the pat to the LaTeX binary?

Best,
Uwe Ligges


 > Duncan Murdoch
 >
 >
 >> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
 >> quiet,  :
 >>    pdflatex is not available
 >> Error in running tools::texi2pdf()
 >> You may want to clean up by 'rm -Rf
 >> C:/Users/edmon/AppData/Local/Temp/RtmpWkD7Iy/Rd2pdf35d81e3e188c'
 >> * DONE
 >>
 >> Status: 1 ERROR, 1 WARNING, 2 NOTEs
 >>
 >>
 >> Then, I tried debugging by isolating errors from the Rd to PDF
 >> conversion.
 >>
 >>
 >> C:\Users\edmon\Documents\R\RFIN> R CMD Rd2pdf avfintools --no-clean
 >> Hmm ... looks like a package
 >> Converting Rd files to LaTeX ...
 >> Creating pdf output from LaTeX ...
 >> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
 >> quiet,  :
 >>    pdflatex is not available
 >> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
 >> quiet,  :
 >>    pdflatex is not available
 >> Error in running tools::texi2pdf()
 >> You may want to clean up by 'rm -Rf .Rd2pdf27964'
 >>
 >>
 >> In this folder is the file Rd2.tex which I tried to complie into a
 >> pdf. But
 >> this error returns and PDF cannot be compiled. :
 >>
 >>
 >> LaTeX Error: File `Rd.sty' not found.
 >>
 >> Type X to quit or  to proceed,
 >> or enter new name. (Default extension: sty)
 >>
 >> Enter file name:
 >> ! Emergency stop.
 >> 
 >>
 >> l.4 \usepackage
 >>     {makeidx}^^M
 >> ==> Fatal error occurred, no output PDF file produced!
 >>
 >>
 >> Thanks for your help,
 >>
 >> [[alternative HTML version deleted]]
 >>
 >> __
 >> R-package-devel@r-project.org
 mailing list
 >> https://stat.ethz.ch/mailman/listinfo/r-package-devel

 >
 > __
 > R-package-devel@r-project.org
 mailing list
 > https://stat.ethz.ch/mailman/listinfo/r-package-devel




__
R-package-devel@r-project.org mailing

[R-pkg-devel] Read and restore .Random.seed in package

2022-09-19 Thread Jan van der Laan



I have a function in which I need to draw some random numbers. However, 
for some use cases, it is necessary that the same random numbers are 
drawn (when the input is the same) [1]. So I would like to do a set.seed 
in my function. This could, however, mess up the seed set by the user. 
So what I would like to do is store .Random.seed, call set.seed, draw my 
random numbers and restore .Random.seed to its original value. For an 
example see the bottom of the mail.


Am I allowed on CRAN to read and restore .Random.seed in a package 
function? This seems to conflict with the "Packages should not modify 
the global environment (user’s workspace)." policy. Is there another way 
to get the same random numbers each time a function is called without 
messing up the seed set by the user? [2]]


Thanks.
Jan

[1] Records are randomly distributed over cluster nodes. For some use 
cases it is necessary that the same records end up on the same cluster 
nodes when the function is called multiple times.


[2] A possible solution would be to document that the user should ensure 
that the same seed is used when calling this function for the use cases 
where this is needed.



set_seed <- function(seed, ...) {
  if (!exists(".Random.seed")) set.seed(NULL)
  old_seed <- .Random.seed
  if (length(seed) > 1) {
.Random.seed <<- seed
  } else {
set.seed(seed, ...)
  }
  invisible(old_seed)
}

foo <- function(n) {
  old_seed <- set_seed(1)
  on.exit(set_seed(old_seed))
  runif(n)
}

Using these:

> set.seed(2)
> foo(5)
[1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819
> runif(5)
[1] 0.1848823 0.7023740 0.5733263 0.1680519 0.9438393
> foo(5)
[1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819
> runif(5)
[1] 0.9434750 0.1291590 0.8334488 0.4680185 0.5499837

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel