r-package

Masking methods in R

和自甴很熟 提交于 2019-12-20 17:35:13
问题 This question and in particular this answer brought up the following question: How can I get a warning about the masking of methods in R? If you run the following code in a clean R session, you'll notice that loading dplyr changes the default method for lag . lag(1:3, 1) ## [1] 1 2 3 ## attr(,"tsp") ## [1] 0 2 1 require(dplyr) lag(1:3, 1) ## [1] NA 1 2 If you attach the package dplyr , you get warnigns for several masked objects, but no warning about the default method for lag being masked.

Creating custom R package with data.table custom function

旧街凉风 提交于 2019-12-20 04:28:15
问题 I wanted to create a package following these very clear and simple instructions, https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/ However the following function works when it is not inside a package, but does not work when in a package. To reproduce this, run the following command in your default folder: Step 1 library("devtools") library(roxygen2) create_package("poweR") This will take you to a new window and in that window: Step 2 exploit_url.R: Create and Copy this to

Including Command Line Scripts with an R Package

拈花ヽ惹草 提交于 2019-12-19 05:50:45
问题 I am interested in providing a command line interface to an R package called Slidify that I am authoring. It uses Rscript and I think that would make it cross-platform. The scripts are stored in the subdirectory inst/slidify . In order to use the script from any directory, I added its path to my .bash_profile as I am on a Mac. My question is How should I handle installation of the script in an automated cross-platform way? How can I make sure that the file permissions are retained in this

How to define “hidden global variables” inside R packages?

喜夏-厌秋 提交于 2019-12-19 05:46:30
问题 I have the following 2 functions in R: exs.time.start<-function(){ exs.time<<-proc.time()[3] return(invisible(NULL)) } exs.time.stop<-function(restartTimer=TRUE){ if(exists('exs.time')==FALSE){ stop("ERROR: exs.time was not found! Start timer with ex.time.start") } returnValue=proc.time()[3]-exs.time if(restartTimer==TRUE){ exs.time<<-proc.time()[3] } message(paste0("INFO: Elapsed time ",returnValue, " seconds!")) return(invisible(returnValue)) } The function exs.time.start creates a global

checking CRAN incoming feasibility … NOTE Maintainer

微笑、不失礼 提交于 2019-12-18 13:52:17
问题 When I run R CMD check --as-cran on my package, the one note I still get is: checking CRAN incoming feasibility ... NOTE Maintainer:[my name] <my email> I can't seem to find a good explanation of this note, although I haven't read anything that tells my I should be concerned about it. As anyone else run into this? Is there anything I can do that will clear the note? 回答1: According to CRAN Maintainer Uwe Ligges, This is just a note that reminds CRAN maintainers to check that the submission

R: How to convert graphNEL object into Adjacency Matrix

南楼画角 提交于 2019-12-13 07:37:27
问题 This is my graphNEL object >mergedPathways_d A graphNEL graph with undirected edges Number of Nodes = 41 Number of Edges = 102 I have tried coerce . It did not work out. It asks to pre-define the matrix and To and From didnot work correctly, I had NA as entries in my adj matrix I tried using edgeL . It did not work out. The edge list I got had numbers as edges and not the names of the genes. And I don't know how to map genes onto those numbers. I tried converting it into igraph using igraph

R package which imports SparkR (not on CRAN)

匆匆过客 提交于 2019-12-13 05:33:57
问题 This question is related to this: when you are writing a package, how to specify a dependency (either in Imports or Depends ) on an existing R package which is not on CRAN. I am writing an R package that imports SparkR , which is not in CRAN anymore (it is delivered with Spark in the R folder). I have tried adding the GitHub link to http://github.com/apache/spark/tree/master/R/pkg in the Additional_repositories field of my DESCRIPTION file, with no luck since the R CMD commands (install,

Forcing a serial compilation on make for R package

你。 提交于 2019-12-12 19:12:14
问题 I submitted a package to CRAN (sundialr) around 6 months back which was recently archived as it fails with the parallel version of make . The exact error message from one of CRAN maintainers is as follows This have just failed to install for me with a parallel make: g++ -std=gnu++98 -std=gnu++98 -shared -L/data/blackswan/ripley/extras/lib64 -L/usrlocal/lib64 -o sundialr.so cvode.o RcppExports.o -L/data/blackswan/ripley/R/R-patched/lib -lRlapack -L/data/blackswan/ripley/R/R-patched/lib -lRblas

Writing R package that call Fortran library

断了今生、忘了曾经 提交于 2019-12-12 13:34:30
问题 I'm trying to write an R package that calls a Fortran subroutine. I'm using Rstudio package template that creates a bunch of files and directories automatically. In ./R/ I have a single file, Fpi.R Fpi <- function(DARTS, ROUNDS) { if (!is.loaded('Fpi')) { dyn.load("./src/Fpi.so") } retvals <- .Fortran("pi", avepi = as.numeric(1), DARTS = as.integer(DARTS), ROUNDS = as.integer(ROUNDS)) return(retvals$avepi) } In ./src/ I have Fpi.f90 subroutine dboard(darts, dartsscore) implicit none integer,

Error while installing a tar.gz package in R

左心房为你撑大大i 提交于 2019-12-12 12:20:10
问题 When i try to install a R package nlopt-2.4.2.tar.gz from http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz , using sudo R CMD INSTALL nlopt-2.4.2.tar.gz , I get the following Error : Error in untar2(tarfile, files, list, exdir, restore_times) : unsupported entry type ‘’ 回答1: It's not an R package! If you perform the tar, zip dance: tar xvfz nlopt-2.4.2.tar.gz and look at the README, you get: NLopt is a library for nonlinear local and global optimization, for functions with and without