An error when install R package forecast on AWS instance

install.packages('forecast') Installing package into ‘/usr/lib64/R/library’ (as ‘lib’ is unspecified) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/forecast_5.4.tar.gz' Content...

Can't run Rcpp function in foreach - "NULL value passed as symbol address"

Let me say first that I've read Writing R Extensions, the Rcpp package vignette, and that I've built a package from Rcpp.package.skeleton(). Since building my package, I added a function,...

How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

I tried to install a package, using install.packages("foobarbaz") but received the warning Warning message: package 'foobarbaz' is not available (for R version x.y.z) Why doesn't R think that...

Returning an instance of a class allocated on the heap (C++)

The program I'm presently working on is written like a script with the exception of 1 class that I'm using (or attempting to) to associate 3 variables with each other. I have a class called...

Fast pnorm() computation on really long vector (of length ~1e+7 to ~1e+8)

Is there a way to optimize pnorm? I am having some bottleneck in my code and after a lot a optimization and benchmark I realized that it comes from the call to pnorm on really big vectors. With...

lapply vs for loop - Performance R

It is often said that one should prefer lapply over for loops. There are some exception as for example Hadley Wickham points out in his Advance R book. (http://adv-r.had.co.nz/Functionals.html)...

math.h not found when using openmp (llvm) with sourceCpp

I am trying to use openmp in my Rcpp code and encounter some issues (Mac OS). Have tried googling a lot but not able to find a solution that works for me. Would appreciate if you can provide some...

Unable to install gdtools or svglite

I need to install svglite, but an error comes up saying I need gdtools first, so I try to install gdtools and get the following error: > install.packages("gdtools",...

Object files in R-package too large (Rcpp)

I am using Rcpp to integrate C++ code into an R-package. After compiling, I see that the *.o files are huge (~2Mb), while the original *.cpp and *.h files are only ~20kb. Where does this...

Using columns of big.matrix in fisher.test in Rcpp

I have a very large binary big.matrix and also a vector of class assignment (same length as number of rows of big.matrix). I want to be able to loop through each column of the big.matrix and...

R Error in install.packages : permission denied

I'm trying to install packages employing the command install.packages() in Rstudio Version 1.1.453: R version 3.5.0 (2018-04-23) -- "Joy in Playing" Copyright (C) 2018 The R Foundation for...

devtools::build() cannot stat directories that exist

I'm using devtools to build a package that has packrat enabled. When I issue the command devtools::build() I get the following: '/usr/lib64/R/bin/R' --no-site-file --no-environ --no-save...

R install.packages returns 'ERROR: failed to lock directory'

[Similar question to 14382209 but suggestions there haven't solved this issue] New installation of R 4.0.0 and tidyverse on a Windows 7 work computer returns this classic failed to create lock...

How to update R from 3.x to 4.x and should I?

With R 4.0.0 and recently R 4.0.1 being released recently, I would like to know how to upgrade? Previously I used UpdateR from the installR package. Will it work just as well upgrading to 4.x? The...

how to create a Rcpp NumericVector from Eigen::Tensor without copying underlying data

If I create a large Tensor in Eigen, and I like to return the Tensor back to R as multi-dimension array. I know how to do it with data copy like below. Question: is it possible to do it without...

Subsetting Eigen vectors and matrices with a vector of indices

I'm trying to port a working Armadillo function to Eigen and am having an issue with RcppEigen vector and matrix subsetting. Here's my function: //[[Rcpp::depends(RcppEigen)]] #include...

Alternative to for loop for fast calculations when equations depend on each other

I am using a for-loop to do step-by-step calculations where several equations depend on each other. Because of this dependence, I cannot find a solution where I do the calculations inside a...

How to install RcppArmadillo on Apple Silicon (M1) Macs

I've been trying many different ways to install RcppArmadillo, but I don't get it to...

RcppEigen functions are very fast with sourceCpp but very slow when compiled as a package

I've written an RcppEigen package with extensive OpenMP usage, all of which is in a single .cpp file. When I compile the code using Rcpp::sourceCpp() everything is extremely fast -- amazing. When...

Mac OS Big Sur R compilation error: ld: framework not found CoreFoundation

After my Xcode automatically updated itself to 12.4, my Rstudio package compilation breaks and throws the following error: ld: framework not found CoreFoundation collect2: error: ld...

Error: package or namespace load failed for ‘sf’

I am trying to install the package sf, but no success. Firstly, I thought the issue was related to the libraries GDAL, GEOS and PROJ, but all of them are installed and recognized by the...

Installing R on OSX Big Sur (EDIT: and Apple M1) for use with Rcpp and openMP

There's probably a gazillion threads on OSX+Rcpp+openMP, but the bottom line right now appears to be this (per coatless): Unfortunately, with R 4.0.0 the CRAN distributed version of R loses the...

Rcpp package doesn't include Rcpp_precious_remove

I have been trying to create a database and installed the "DBI" package, but I am still facing this error. I reinstalled DBI and RSQLite package, but they don’t seem to work. library("DBI") con...

data partitionning function CreateDataPartition cross validation problem

I am trying to get predictions of a multiple variables model, its eplt, its made of 7 scores and one final exam score moy_exam2, I want to predict the later using the 7 scores, I have 29441...

libstdc++.so.6: version `GLIBCXX_3.4.26' not found on Linux

I was trying to load Seurat package in rstudio and got this error Error: package or namespace load failed for ‘Seurat’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object...

Why is this Rcpp code not faster than pure R?

Setting up I tried some R and Rcpp benchmarks with Fibonacci numbers. Pure R We use the fibR function for the code that was written in pure R. fibR <- function(n) { if (n < 2) n ...

How can I use Octave from R 4.1?

I've installed Octave in Linux machine (Ubuntu 20.04) using this code: sudo apt-add-repository -y ppa:octave/stable; sudo apt install -y software-properties-common; sudo apt-get update; sudo...

Is it possible to do Rcpp::wrap without copying for a very large std::vector

I have an Rcpp function that reads large BAM file (1-20GB, using htslib) and creates several very long std::vectors (up to 80M elements). The number of elements is not known before reading, so I...

Python script works in vscode but not rstudio

We have some python code that takes an excel file as input and processes it into a json file for some javascript to visualize. To complicate this further, the javascript (and a bunch of other...

Fastest way to construct the sequence `c(1:1, 1:2, ..., 1:n)`

For a given positive integer n, I want to know the fastest base R (not Rcpp) algorithm for constructing the integer vector c(1:1, 1:2, ..., 1:n), which has length n*(n+1)/2. There are bonus points...

Relevant tags