Modify BiasedUrn R package - r

I was trying to modify the BiasedUrn package to be able to generate more random numbers. The current limit is 32 random numbers.
I followed the steps provided by [1].
I had a hard time dealing with the error below. I finally added one more option as R CMD build BiasedUrn --no-manual to temporarily get rid of the error.
Now I successfully built and installed the modified package. However, whenever I run a function from this new package in R Studio, the program quits abruptly.
P.S. The only change that I make is in the Makevars file (from -DMAXCOLORS=32 to -DMAXCOLORS=10000).
Any idea how I can fix this issue?

Related

r: errors creating package with devtools & roxygen2

I'm writing a package containing several functions to make running and evaluating models more streamlined.
I have a function that I'm going to make the first function within my package detailed with roxygen2 comments, which I can include into this write-up as an edit if necessary, but my issue is more with Package Creation.
I've created a separate .R file for the function and it lives within the R folder in within my package folder. I've run R CMD build pkgname and R CMD INSTALL pkgname successfully.
At the document() stage I run it (from console or whether in my terminal using R -e 'library(devtools);document()', deleting the existing NAMESPACE file first) and I get the following error: Try removing ‘/Library/Frameworks/R.framework/Versions/ 3.5/Resources/library/00LOCK-pkgname.
I've already seen the [issue posted here][1] and haven't had success after deleting the 00LOCK-pkgname folder, for two reasons: when I run document(), even when it throws the above error, it doesn't stop running, it just keeps looping (that happens whether I run this in R or use the Terminal). Additionally, no matter how many times I delete the folder, it keeps re-appearing even though I've stopped running the function.
Any insight into why that error is being thrown and the document() function continually runs in a loop?
Best answer I've found is in this blog post: Hilary Parker R-Package Blog Post
The steps I follow to document and install are as follows:
Within the project that contains my package, open a new R Script and run setwd('..')
Run devtools::document()
Run devtools::install()
This works for me when initially installing my package and also updating it.

R CMD Check does not finish the step "Checking PDF version of manual ..."

I am creating an R package using R Studio version 0.99.489 together with the most current R development version on Windows 7. I created documentation .Rd files using roxygen2 and a .Rmd vignette using knitr. Until now everything worked out fine, but when I run the R CMD check within RStudio, the check gets stuck at the step "Checking PDF version of manual ...". I neither get an "OK" nor any error or warnings message. The step just does not proceed, even if I run it over night. I do not get any error or warning messages for the other steps as well, I have "OK"s everywhere.
Consequently, I do not find a PDF manual in the package.Rcheck folder. I already created the manual myself using R CMD Rd2pdf package, which worked out fine. I copied it to several locations within the package folder but this did not help at all.
I searched really a lot but I could not find any solution for this since I do not get any error message. I thought about administration, latex, or R version problems, but I cannot figure out if it is any of those or something else.
One thing I recognized is that when the package is build, it prints out:
CMD build "..PATH...\package" --no-resave-data \ --no-manual
although I did not specify the --no-manual option in the Build options from RStudio. Additionally, I did not find a way to change this. Might this be the problem?
Can anyone help me with this? I would really appreciate any hints. Please let me know if you need any output or any other information from me.
Thanks!
You could do it yourself using:
shell('R CMD Rd2pdf . --output=man/figures/manual.pdf --force --no-preview')
This will create the PDF and save it to yourpackage/man/figures/manual.pdf.
I use it, so I know it works before I send it to CRAN.
I faced the same problem. It was really frustrating that it didn't give any error message. But then I tried this:
install.packages("devtools")
Actually I don't really know how it works, but I guess it also install other requirements and now the checking process is done via devtools and not directly by roxygen2. Hope it helps.
I also come across with this problem, which I think it's a bug of RStudio. Try R CMD check <YOUR PROJECT NAME> in terminal, in my case, it finally generates an error,
* checking PDF version of manual without hyperrefs or index ... ERROR
Re-running with no redirection of stdout/stderr.

How to autoupdate version number on successful build of an R package

I found this article (original) about how to auto update a package version number in R.
I would like to implement it in the same way as they suggest but I fail at the point to create my own Makefile to build a package.
The function they provide is working fine.
Can anyone help me to create a Makefile to check, build, if both are successful increase the version number, build under new version number. Within RStudio it is possible to select Makefile as build tool.
In general I like the idea to have all development packages with a 4th version number like 0.1.2.9001. At the moment I always overwrite my packages and only set three numbers manually like 0.1.3.

Profiling an installed R package with source line numbers?

I'd like to profile functions in an installed R package (data.table) using Rprof() with line.profiling=TRUE. Normally, installed package are byte compiled, and line numbers are not available for byte compiled packages. The usual instructions for line profiling with Rprof() require using source() or eval(parse()) so that srcref attributes are present.
How can I load data.table so that line numbers are active? My naive attempts to first load the package with library(data.table) and then source('data.table.R') fails because some of the compiled C functions are not found when I attempt to use the package, presumably because library() is using a different namespace. Maybe there is some way to source() into the correct namespace?
Alternatively, perhaps I can build a modified version of data.table that is not byte compiled, and then load that in a way that keeps line numbers? What alterations would I have to make, and how would I then load it? I started by setting ByteCompile: FALSE and then trying R CMD INSTALL -l ~/R/lib --build data.table, but this still seems to be byte compiled.
I'm eager to make this work and will pursue any suggestions. I'm running R 3.2.1 on Linux, have full control over the machine, and can install anything else that is required.
Edit:
A more complete description of the problem I was trying to solve (and the solution for it) is here: https://github.com/Rdatatable/data.table/issues/1249
I ended up doing essentially what Joshua suggested: recompile the package with "KeepSource: TRUE" in the DESCRIPTION. For my purposes, I also found "ByteCompile: FALSE" to be helpful, although this might not apply generally. I also changed the version number so I could see that I was using my modified version.
Then I installed to a different location with "R CMD INSTALL data.table -l ~/R/lib", and loaded with "library(data.table, lib='~/R/lib')". When used with the patches given in the link, I got the line numbers of the allocations as I desired. But if anyone knows a solution that doesn't require recompilation, I'm sure that others would appreciate if you shared.
You should be able to get line numbers even if the package is byte-compiled. But, as it says in ?Rprof (emphasis added):
Individual statements will be recorded in the profile log if
line.profiling is TRUE, and if the code being executed was
parsed with source references. See parse for a discussion of
source references. By default the statement locations are not
shown in summaryRprof, but see that help page for options to
enable the display.
That means you need to set KeepSource: TRUE either in the DESCRIPTION file or via the --with-keep.source argument to R CMD INSTALL.

Undocumented data sets: '.Random.seed' (R CMD check)

I'm building an R package and have run into a perplexing warning during R CMD check:
* checking for missing documentation entries ... WARNING
Undocumented data sets:
‘.Random.seed’
The package has one small data set, which is documented. I'm using R 3.1.1 and RStudio 0.98.1062 on OS X Yosemite, but I get the same error on Windows 7 (and from CRAN). The project also has a vignette that is built with knitr. devtools etc. are all up to date. The file '.Random.seed' doesn't exist in the "data" folder before building, and my reasoning is that it's getting transiently written to disk during the build process by...something. I tried adding '.Random.seed' to .Rbuildignore without success, presumably because it doesn't exist when the build process begins.
Has anyone encountered this before?
Ran into this problem as well. You have almost certainly solved it by now, but I'll post an answer just in case somebody else hits the same problem. At some point, you generated a random number or set the seed in the creation of the Rdata file (or at least that's what happened to me). Simply load the workspace from you data folder, and rm(.Random.seed). Save it. You're done. Easy as pie.
http://www.inside-r.org/r-doc/base/set.seed
I had a similar problem when I was uploading the my.csv dataset, if anyone faces a similar problem the answer is inhere.

Resources