cran

Using a static (prebuilt) PDF vignette in R package

蹲街弑〆低调 提交于 2019-11-27 21:58:18
What is the proper way, to include a static PDF file as a "vignette" in a CRAN package as of R 3.0? The trick described in this document of using an empty stub Rnw does not seem to work in R 3.0. The document suggests that there is now a better way based on \VignetteEngine{} but it's not quite clear how this works for static PDF files. With R.rsp (>= 1.19.0) you can include a static PDF 'vignettes/main.pdf' by adding a tiny 'vignettes/main.pdf.asis' text file that contains: %\VignetteIndexEntry{My amazing package} %\VignetteEngine{R.rsp::asis} and make sure to have: Suggests: R.rsp

Package dependencies when installing from source in R

為{幸葍}努か 提交于 2019-11-27 20:36:20
Just confirming: If I distribute my R package as ZIP/TAR then installing the package will not automatically download/install dependencies because I have to set repos = NULL in install.packages() and dependencies parameter is not used if repos = NULL ? The way to possibly get this to work is to package an install script. Is that possible? Am I completely missing something here and there is a mechanism to install from source AND automagically download and install dependencies? You could make your own repository and set repos to be a vector of the places to look for packages, where it would start

Combining S4 and S3 methods in a single function

回眸只為那壹抹淺笑 提交于 2019-11-27 14:25:24
What is a good way of defining a general purpose function which should have implementations for both S3 and S4 classes? I have been using something like this: setGeneric("myfun", function(x, ...){ standardGeneric("myfun"); }); setMethod("myfun", "ANY", function(x, ...) { if(!isS4(x)) { return(UseMethod("myfun")); } stop("No implementation found for class: ", class(x)); }); This succeeds: myfun.bar <- function(x, ...){ return("Object of class bar successfully dispatched."); } object <- structure(123, class=c("foo", "bar")); myfun(object) Is there a move "native" way to accomplish this? I know

R: apt-get install r-cran-foo vs. install.packages(“foo”)

旧街凉风 提交于 2019-11-27 11:28:39
When installing R packages (say mcmcpack in this example) under Ubuntu I have the choice between the following two methods of installation: # Let the distribution's packaging system take care of installation/upgrades apt-get install r-cran-mcmcpack # Let R take care of installation/upgrades install.packages("mcmcpack") Questions: Is any of the two ways of installing R packages considered "best practice"? Assume that I first install.packages("mcmcpack") and later on apt-get install r-cran-mcmcpack - should I expect trouble? Assume that I first apt-get install r-cran-mcmcpack and later on

Install a local R package with dependencies from CRAN mirror

三世轮回 提交于 2019-11-27 10:28:13
问题 I have built an R package, i.e. I have the mypackage.tar.gz file. This package depends on several other packages, all downloadable and installable from any CRAN mirror. Now I want to install this package on a system where the dependencies are not yet installed, and I would like that the dependencies will be downloaded and installed automatically when I install my package. I tried: install.packages("mypackage.tar.gz",type="source",dependencies=TRUE,repos="http://a.cran.mirror") but it searches

How can I load dependencies in an R package?

佐手、 提交于 2019-11-27 08:13:01
问题 I am developing an R package where this is available in the DESCRIPTIONS file Imports: dplyr, ggplot2, ncdf4 And I have an example function where I use the third dependency testFun <- function(file, lat, long){ ncfname <- file.path(file,fsep = .Platform$file.sep) xfile <- nc_open(ncfname) #Opens the NetCDF file lat <- ncvar_get(xfile, 'lat') #Extracts all latitudes ...Calculations return(XYZ) } When I Build and Reload the package, and I run the function, it could not find function "nc_open" .

How to tell CRAN to install package dependencies automatically?

元气小坏坏 提交于 2019-11-27 06:57:05
I develop a package in R and when I check and build it in my local computer it works properly. But when I tried it in CRAN, I get a package dependencies error. My package depends on two functions of other packages. If I list the other packages under the description using Depends or imports , will it be automatically installed with the new package? Or do I need to explicitly invoke the function install.packages("packagename") under the function that I've used the other packages. if this all is wrong, what is the best way to solve package dependencies in R inorder to pass the R CMD check and

Set default CRAN mirror permanent in R

旧街凉风 提交于 2019-11-27 06:56:31
How can I set a specific CRAN mirror permanently in R? I want to set it permanently in my laptop so that when I do install.packages() , it won't ask me again which mirror to choose. rinni You can set repos in your .Rprofile to restore your choice every time you start R Edit: to be more precise: Add options(repos=structure(c(CRAN="YOUR FAVORITE MIRROR"))) to your .Rprofile Alternatively, you can set the mirror site-wide in your Rprofile.site . The location of the file is given by ?Startup : The path of this file is taken from the value of the R_PROFILE environment variable (after tilde

How to select a CRAN mirror in R

旧巷老猫 提交于 2019-11-27 02:36:13
I'm trying to install a package through the R prompt by doing the following: install.packages('RMySQL') But the output is as follows: --- Please select a CRAN mirror for use in this session --- And nothing else! I can't find a solution to this very basic problem. What am I supposed to type in order to select a CRAN mirror? EDIT: OS: Mac-OS X 10.6.8 R Version: 2.15.0 You should either get a window with a list of repositories or a text menu with some options. But if that is not appearing, you can always specify the mirror from where to download the packages yourself by using repos parameter. By

How do I get rmarkdown 1.2 with Microsoft R Open 3.3.2

好久不见. 提交于 2019-11-27 02:33:36
问题 I am using RStudio 1.0.136 with Microsoft R Open 3.3.2 When I do File --> New File --> R Markdown... it says rmarkdown 1.2 is required but 1.1 is available And Check that getOption("repos") refers to a CRAN repository that contains the needed package versions And getOption("repos") gives me this: CRAN "https://mran.revolutionanalytics.com/snapshot/2016-11-01" CRANextra "http://www.stats.ox.ac.uk/pub/RWin" Where do I go from here? 回答1: One of the things we do with MRO (and other MS R