RStudio and devtools do not install static vignettes - r

I created an R package for an introductory course in remote sensing with R (github link) and want to provide the handouts as as static PDF vignettes (copy protected) as described here. With the standard Linux commandline "R CMD build FEglobaleOekologie && R CMD INSTALL FEglobaleOekologie_0.0.1.tar.gz" everything works fine. However, when I install it from within my RStudio project or under MS Windows with devtools::install_github" there are no vignettes. The later one is the target platform, where I would like to have them.
Sadly I could not find any thread, that solves my problem. Can anyone tell what's going wrong here or what I am doing wrong?

I've run into problems like this, too. I've found that build doesn't always build my vignettes (that generally happens with using build in the RStudio menu, since I believe that doesn't include the vignettes by default ). You might want to try also running build_vignettes() before uploading to GitHub; and when installing from GitHub, explicitly including build_vignettes = TRUE in the install_github function. Otherwise, you may have a path issue for the installed package.

Related

R CMD INSTALL --build package --> "vignettes missing"

Problem:
C:\>Rcmd.exe INSTALL --build --library=C:/Users/local_aphalo/Documents/R/win-library/3.0 photobiology
C:\>Rcmd.exe INSTALL --build --library=C:/Users/local_aphalo/Documents/R/win-library/3.0 photobiology_0.2.6.tar.gz
The first command (as used by RStudio) builds a ZIP file that is missing the vignettes.
The second command builds a ZIP that includes the vignettes.
Using R CMD instead of Rcmd.exe makes no difference. The .tar.gz was built immediately before attempting to build the .zip file, from exactly the same source files, from within RStudio (which uses Rcmd.exe build photobiology).
The vignettes are coded in .Snw files using knitr, documentation and NAMESPACE use ROxygen2. The problem happens on all of the packages that I have tried to build, but they are very similarly coded. Only one of them uses Rcpp.
When installing the package for use from within RStudio, installing from .tar.gz installs vignettes just fine. If installing from .zip, whether vignettes get installed or not, depends on whether the .zip files contains them or not (which depends on which of the two commands at the top of this message was used to build the .zip file).
I am using R 3.0.1, and also tried a couple of R 3.0.1 patched builds a few days back. I am mostly using Windows 7 (both 32 bit, and 64 bit), I tried once under Ubuntu 64bit, and the problem is reproducible. I first noticed the problem when using RStudio (0.97 and 0.98) and posted a message in the RStudio forum, but have received no answer in a couple of weeks. I have found at least another relatively old post about this problem in the RStudio website forum, but it has not been answered. Today, I investigated a bit further, and the problem is clearly not related to RStudio, as I can reproduce it through the command line.
The question is: Is this behavior a feature? a bug? or I am missing just an option in the command used?
Of course, I can easily work around the problem at the command line by using the .tar.gz file to build the .zip file, but as I think the preferred way of building a package is by just supplying the package name as argument.
Thanks for any insights on the origin of this problem.
I think this is a feature:
if you're installing from source, vignettes are always built
if you're installing from a binary, they're not built, and will only be available if they were built when the binary was made
This approach means that you can distribute vignettes in binary packages to people who might not be able to build them from source.

How can I access Windows COM objects in R v3?

Some time ago, you used to be able to install the rcom package in R to use COM scripting (eg, access to external programs.) Unfortunately, it seems to be discontinued:
Package ‘rcom’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
This depends on statconnDCOM, which nowadays restricts use, contrary
to the CRAN policy for a package with a FOSS licence. See
http://rcom.univie.ac.at/ and http://www.statconn.com/.
Following the archive and statconn links and installing one of the older versions in R version 3 gives the error:
“Error: package ‘rcom’ was built before R 3.0.0: please re-install
it”.
I am not very familiar with R, but there seems no way around this message - after all, it occurs when installing, so re-installing doesn't seem to be the answer. It appears as though rcom is simply not available for recent (3.0+) versions of R. I have also scanned the package list, although searching for "COM" there returns over a hundred results and it is possible I missed the right one when clicking through them.
How can I use the rcom package, or use COM from within R some other way?
(Note: I am asking this question on behalf of a colleague. I have no experience with R myself at all. Both of us, when searching for answers, could not find anything. I am sure that others are also using COM in the latest version of R, though!)
I looked at the rcom source code a few months ago. It seems I can get it to build and install OK on R3.0.1. Below is the procedure if it helps.
Get a checkout of the latest source code of rcom. I have rcom_2.2-5.tar.gz locally. I can google something at the following address, but I have no idea of the provenance, so up to you to check it is legit. http://cran.open-source-solution.org/web/packages/rcom/index.html
in R do install.packages('rscproxy')
install Rtools as per the instructions on the R web site (http://cran.r-project.org/bin/windows/Rtools),
open a Windows command prompt i.e. run "CMD"
go to the folder containing the 'rcom' folder, and at the command prompt:
set R="c:\Program Files\R\R-3.0.1\bin\i386\R.exe"
%R% CMD check --no-manual rcom
check it passes without too many complaints. Your call as to the --no-manual option (if you have MiKTeX installed you may remove it)
%R% CMD INSTALL rcom
should result in
installing to c:/Rlib/rcom/libs/i386
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
rcom requires a current version of statconnDCOM installed.
To install statconnDCOM type
installstatconnDCOM()
This will download and install the current version of statconnDCOM
You will need a working Internet connection
because installation needs to download a file.
* DONE (rcom)
in R:
library(rcom)
installstatconnDCOM()
I tried a comRegisterRegistry() ; comRegisterServer()
; x<-comGetObject("Excel.Application") but I get a NULL for x. I am not a user of rcom so while it all seems to compile fine; it may just not work anymore.
If you happen to need to access .NET code, a viable option (and yes I have a vested interest in mentioning it) may be the rClr package.
Hope this helps; I'd be interested to hear how you go.
This really should be a comment, but I don't have enough rep points yet to leave one.
I found that the above steps did not work for me, but the answer posted by Lisa Ann on this question, RExcel in R 3.0.x, did solve my problem installing rcom. Since you need rcom to run RExcel, the initial steps to install RExcel cover installing rcom on newer versions of R (such as 3.0.2).
Specifically, following the advice on statconn's wiki, http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:how_to_install
You also need to follow these instructions if you upgrade R, i.e. you install a new >release of R after you have installed RExcel.
Download the statconn DCOM server and execute the program you downloaded
Start R as administrator (on Windows 7 you need to right-click the R icon and click the >corresponding item)
In R, run the following commands (you must start R as administrator to do this)
install.packages(c("rscproxy","rcom"),repos="http://rcom.univie.ac.at/download",lib=.Library)
library(rcom)
comRegisterRegistry()
Now you have rcom installed, [instructions for installing RExcel follow...]
New versions of rcom and rscproxy (also for current versions of R) are available from a different repository. Just use http://rcom.univie.ac.at/download as the R repository to install from and you can download and install binary versions of statconn packages from there.
Hope this helps!

Installing R packages on Windows 7

On Windows 7 x64, I've got version 3.0.0 of R installed. Further, I've also set the environment variable R_LIBS_USER to point to a network drive. In rgui.exe, executing:
Sys.getenv("R_LIBS_USER")
outputs the same value that I previously set above. Also from R, installing packages into the personal library pointed to by R_LIBS_USER works fine. So far, so good.
With version 0.97.551 of RStudio installed, executing the same code above through RStudio also outputs the same value (as expected). However, from RStudio, my attempts at installing packages into the personal library fails. The error message effectively states that RStudio is unable to write to the personal library defined by R_LIBS_USER.
Before posting to stackoverflow, I checked the support forum for RStudio (http://support.rstudio.org/help/discussions/problems/4608-change-personal-library-for-installing-packages) where an admin states that the problem has to do with R and not RStudio. The admin goes on to reference the RStudio document generated by code
?.libPaths
in the RStudio IDE. The admin also provides additional guidance through link http://support.rstudio.org/help/kb/troubleshooting/getting-help-with-r.
After reviewing the IDE-generated document and forum link, I've determined that my environment is set up correctly. And yet, RStudio still fails.
Has anyone been able to get RStudio personal library working with a filesystem location other than the defaults?
I should clarify my needs a bit more. The environment to which this application will eventually be deployed prohibits normal users from running RStudio as administrators, hence the focus on R_LIBS_USER personal library. So although I know this would work, it is not a realistic option for me.
What I need is for RStudio to exclusively write to R_LIBS_USER and not attempt to also write to R_HOME (my assumption of what I think it is actually attempting to do.)
Add a line .libPaths("~/your-lib-path-here") to your .Rprofile and restart R. .libPaths() lets you write as well as read the the set of default libraries.
Alternately, if you can control the installation commands (i.e. you need your library to be available but it doesn't have to be the default), most R commands such as install.packages have a lib parameter that lets you manually specify the library to install to.
You might consider using an R package management system such as Packrat, which automates the job of installing your application's dependencies to a private library without you having to set it up manually. (Full disclosure, I'm a contributor to this package.) It works under RStudio.

How can I build a stand alone R engine with some packages included?

I have a windows server that does not allow me to install anything but it allows me to run exe files (Meaning that I cannot simply download the R installation package and install R that way). I want to run R on it and I like to know if it is possible for me to make an R.exe with some packages like ggplot and lattice included?
Do you have any filestore on the server? I can't imagine that you wouldn't have. You can install packages to any directory, which can then be your own personal library. Look at the help(install.packages) and help(library) and there's a lib or lib.loc argument that tells it where to stick it.
If the reason you can't install is because install.packages can't get through the network to CRAN, then download the binary from CRAN, transfer it to the server, and install that way.
Note that I didn't answer your question about building an R exe with bundled packages (here's that answer: "No") because you thought the answer to that question was the solution to your real problem ("I can't install packages"). Always ask a question to your original problem...
I ran across the portable version of R that could do it for me. It generates a folder that can be moved to the new server.
http://sourceforge.net/projects/rportable/

How do I install an R package from the source tarball on windows?

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.
How do I install an R package from the source on Windows?
I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:
Install rtools, then:
install.packages(path_to_file, repos = NULL, type="source")
Two answers that may help you avoid the hassle of installing Rtools.
Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.
I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.
I'm not sure if this is the best way, but I found the following method to work (based in part on the answers above):
1) Download the package .tar
2) Move the package to the directory with your user R libraries (e.g., in my case it was "C:/Users/yourUserName/Documents/R/win-library/3.3")
3) Within Rstudio (or elsewhere, probably), run the command... install.packages("packageName.tar", repos=NULL, type="source")
That worked for me at least. Hope it's helpful!
Download the package *.tar.gz.
make sure you have Rtools installed.
Make sure the R and Rtools paths are added in the environment varialble.
Open a command prompt. Type R CMD INSTALL packagename.tar.gz.
it will work i hope.
To install a package from a .tar.gz file, follow these steps:
Launch R to have the R command prompt
Type: install.packages(<path_to_tar.gz_file>, repos = NULL)
or launch directly:
R CMD INSTALL <path_to_.tar.gz_file>
You need to have R installed but you don't need RTools

Resources