RStudio: Error on testing documentation with? - r

I'm using latest RStudio 0.99.879. I'm creating a new project as R Package.
After running (as mentioned on http://r-pkgs.had.co.nz/man.html)
devtools::document()
?.
I get an error
/path/to/my/package/man: Sections \title, and \name must exist and be unique in Rd files
What's the reason and how can I avoid it?
Edit: I've deleted manually the file man/hello.Rd so roxygen2 can generate it.

Hadley told me "." is the end of the sentence. So there's no magic.

Related

How I can ease out myself of .Rd file when I am developing an R package

I am developing my own R package using R studio 1.2.1335. Within R folder of my package, I have function r2.R for which I did not build r2.rd file in man folder. When I am checking packgae using command R CMD ..., then I got the following warning message.
checking for missing documentation entries ... WARNING
Undocumented code objects:
'r2'
All user-level objects in a package should have documentation entries.
See chapter 'Writing R documentation files' in the 'Writing R
How I can solve this isue ?
Thanks,
Mahdi.
There are several solutions.
Don't export r2. If it's an internal function, it doesn't need documentation.
Write man/r2.Rd. Running prompt(r2) will give you a skeleton version of the file which you can edit into a real one.
Learn roxygen2 syntax, and put that into your .R source code. It can generate the r2.Rd file.
Personally, I generally do 1 or 2, but lots of people seem to think 3 is preferable. Your choice.

Troublesome package creating

I have some problems with creating package, can you please spot my mistake?
I followed instruction below :
1.Create functions I want in my package
2.Open new project -> R package
3.Create as many R documentation as many functions I implemented, and then put them into man folder
4.Press Ctr+Shift+B to install package.
The warning I'm facing is
Warning: C:/Program Files/R/R-3.6.3/library/mypackage/man/myfun2.Rd:62: All text must be in a section
I search internet about solution to that problem but I found only involved instructions containing other approach. Is there possibility how to fix this ? Or other approach with using other packages is crucial (as roxygen).
Thanks in advance
You should not write the manual pages yourself. You should use roxygen code to write the manual elements in your function R files, then use devtools::document() to generate the manual pages. See here for examples: https://keithmcnulty.github.io/r_package_training/index.html#1

How do I fix errors from R CMD check --as-cran to get my R package accepted on CRAN?

Executive Summary
I need assistance to fix the errors as I attempt to create a manual for a new R package. I have created an R package on my computer that I would like to distribute. At the moment, the package is available as a repository on GitHub (http://www.github.com/greenspb/poker), but I want to contribute it to the Comprehensive R Archive Network. I wrote the code years ago, but never shared it out of fear. This is my first repository on GitHub and my first submission to CRAN. I have researched how to get my package on CRAN by reading a blog post at http://kbroman.org/pkg_primer/pages/cran.html . I am stuck on step 1:
"Run R CMD check --as-cran and eliminate all problems. If there are any errors or warnings, your package will not be accepted at CRAN. And even a “Note” will likely disqualify you. So figure out what all of those errors, warnings, and notes mean and then revise your package so that they are no longer issued."
The report generated by "Run R CMD check --as-cran poker" for my "poker" package ( available as a repository on GitHub ) contains errors. My concern is failure to make the LaTeX manual.
Resolved Issues
I used roxygen2 comment tags in the .R file in the project's R folder. roxygen2::document() successfully translated \cr in a comment tag into a new line in the LaTeX file, however it unsuccessfully translated every empty \tab in a comment tag into {} [empty curly parentheses] in the LaTeX file. This happened in dozens and dozens of instances. The \tabular environment was used in an attempt to preserve formatting. I was able to clean up LaTeX errors whenever "There was no line here to end" by searching for {} and replacing appropriate instances with \\{}.
Unresolved Issues
I have no idea how to solve the LaTeX error "Rd2.tex: File Ended while scanning definition of \LT#xxiii", although I believe \LT stands for long table. I am only able to make pdf manuals of several individual functions using R CMD Rd2pdf on the .rd documentation files.
My code is documented using roxygenize tags. When I execute the Run R CMD check --as-cran command, R encounters errors and warnings and fails to make the pdf for the entire package. I need assistance to fix the errors in the report. I want to get my package on CRAN.
See Also
Question on r-package-devel#r-project.org mailing list.
Removing comments on the local variables was the answer to fixing the errors ( replying to #Dason). Thank you.

After running R CMD Check, the mypackage.Rcheck directory with PDF manual disappeared

I have installed Rtools v.31 and MKTeX2.9 on my laptop before building my R package. After I ran R CMD check, a directory called mypackage.Rcheck and the source file mypackage_1.x.tar.gz appeared, and while RStudio build package function is checking everything, there is no warning or error message, but at the end when it said (as follows), the corresponding mypackage.Rcheck directory which is supposed to contain the PDF manual disappeared:
checking PDF version of manual ... OK
DONE
NOTE: There were 3 notes.
See
'C:/.../package/mypackage.Rcheck/00check.log'
for details.
R CMD check succeeded
I thought it might be a version conflict between Rtools and R because I'm using R13.1.2 and Rtools v.31, where on the http://cran.r-project.org/bin/windows/Rtools/ website, it said the image isn't frozen (which I don't understand what it means). But I tried all the suggested compatible version pairs between Rtools and R, and still couldn't get it working. So I think this disappearing of mypackage.RCheck is not due to version conflict.
I don't think it's MiKTeX problem because apparently pdf is generated, but was consequently removed. I also tried using --options in R CMD check, but there is no way to force generation of pdf manual, plus pdf was generated at one point. I also read one post on this website, suggesting the use of Rutils function Rd2pdf: "R CMD Rd2pdf mypackage", but I can't run in on windows, and Rutils package is not available for R13.1.2.
can someone suggest the source of the problem or if they have seen this problem before and was able to fix it?
In RStudio: Tools -> Global Options -> Packages. There is a setting "Cleanup output after successful R CMD Check". If this is checked it removes the package.Rcheck folder after a successful check. If you uncheck this setting, the package.Rcheck folder is not removed and you will find the reference manual pdf there.
A common problem for mysterious disappearances of files from R tarballs is to accidentally specify that they should be ignored in the .Rbuildignore file. The lines in that file are regular expressions, so leaving off the anchors ^ and $ can cause them to match more files than you intended. For example,
vig.e
matches vignette.pdf (because there are no anchors to the start and end of the name, and the
dot means "any character".

creating package

i am creating a package in R language, everything is running properly, but when i run R CMD check , it shows an error message while running examples.. i.e.
"can't open the file." "No such file or directory"
actually my function needs a PubMed text file containing abstracts from the PubMed, i have placed my text file in every sub-directory of my package, but its not working. showing same error again and again.
so please suggest me the right way how to put a text file in a package which can be used by examples to run properly.
i will be very thankful to you.
Usually you put such data in the /inst folder. E.g.:
<packageRoot>/inst/pubmed/myfile
After the package is build you can access the content of this folder from within the package like this:
system.file( "pubmed/myfile", package="<package>" )
See for more information http://cran.r-project.org/doc/manuals/r-release/R-exts.pdf (1.1.5 Data in packages).
I suggest you to use devtools and roxygen2 packages. Basically, you just need to prepare description and .R files.
see more details in this brilliant answer :devtools roxygen package creation and rd documentation

Resources