I get the following error by starting my application:
While selecting package versions:
error: Conflict: Constraint aldeed:autoform#4.2.0 is not satisfied by aldeed:autoform 5.7.1.
Constraints on package "aldeed:autoform":
* aldeed:autoform#5.2.0 <- top level
* aldeed:autoform#4.2.0 <- meteoric:autoform-ionic 0.1.5
* aldeed:autoform#5.7.0 <- forwarder:autoform-wizard 0.9.0
* aldeed:autoform#4.0.0 || 5.0.0 <- notorii:autoform-datetimepicker 1.0.4
* aldeed:autoform#4.0.0 || 5.0.0 <- lukemadera:autoform-googleplace 1.0.7
* aldeed:autoform#4.0.0 || 5.0.0 <- cfs:autoform 2.2.1
Any ideas how to solve it? :)
Did you try to update?
meteor update
Related
I wish to build a package, but I write part of it using RcppArmadillo and now I am suffering the consequences. I am using roxygen2 and devtools to help me with DESCRIPTION and NAMESPACE. I am coding in R / Ubuntu. In the DESCRIPTION I include two lines to load the packages:
Depends: R (>= 3.4.4), MASS (>= 7.3-49), Rcpp (>= 1.0.5), RcppArmadillo (>= 0.9.900.2.0)
LinkingTo: Rcpp, RcppArmadillo
and in the folder /src I write a script name loss_function.cpp, inside it there is:
> // [[Rcpp::depends(RcppArmadillo)]]
>
> #include <RcppArmadillo.h>
>
> using namespace Rcpp;
>
> //' Check function.
> //'
> //' #param x vector
> //' #param tau percentile
> //' #return y new vector
> // [[Rcpp::export(rho_koenker)]]
> arma::vec rho_koenker(arma::vec x, double tau){
> int n = x.n_elem;
> arma::vec y(n);
> for(int i = 0; i < n; ++i){
> if(x(i)<0){
> y(i) = x(i)*(tau-1);
> } else {
> y(i) = x(i)*tau;
> }
> }
> return(y);
> }
>
> //' Quantile regression loss function
> //'
> //' #param beta parameter
> //' #param x matrix
> //' #param y vector
> //' #param tau percentile
> //' #param N total number of observations
> //' #param d beta's length
> //' #return eta numeric
> // [[Rcpp::export(loss_qr)]]
> double loss_qr(arma::vec beta, arma::mat x, arma::vec y, double tau, int N, int d){
> double eta = 0;
> arma::vec res(N);
> arma::vec rho(N);
> res = y - (x * beta);
> rho = rho_koenker(res,tau);
> eta = accu(rho);
> return(eta);
> }
When I check the package (build -> check package) there comes an error msg:
Error in .Call("_pqfe_loss_qr", PACKAGE = "pqfe", beta, x, y, tau, N, :
"_pqfe_loss_qr" not available for .Call() for package "pqfe"
Calls: qr ... optim_qr -> <Anonymous> -> <Anonymous> -> fn -> .Call
Execution halted
Warning message:
Can't find generic `sew` in package knitr to register S3 method.
This message is only shown to developers using devtools.
Do you need to update knitr to the latest version?
As alluded in the comment above, it is not clear where you error would lie here with RcppArmadillo. So I
invoked RcppArmadillo.package.skeleton() (via the helper command kitten.r from littler relying on pkgKitten but those are details)
added in src/loss_function.cpp based on what you had
added one missing #export tag to you doxygen/roxygen to also have the R documentation created
called Rcpp::compileAttributes() (via helper compAttr.r from `littler) to have the interal glue code generated / updated
called roxygenize() (via helper roxy.r from littler) to have help files created
called R CMD build (directly, or via helper build.r from littler)
ran R CMD check (directly, or via helper rcc.r from littler)
and it all works:
edd#rob:~/git/stackoverflow/73405262(master)$ R CMD build soDemo
* checking for file ‘soDemo/DESCRIPTION’ ... OK
* preparing ‘soDemo’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to process help pages
* saving partial Rd database
* cleaning src
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘soDemo_1.0.tar.gz’
edd#rob:~/git/stackoverflow/73405262(master)$
and checks nicely too
edd#rob:~/git/stackoverflow/73405262(master)$ R CMD check soDemo_1.0.tar.gz
* using log directory ‘/home/edd/git/stackoverflow/73405262/soDemo.Rcheck’
* using R version 4.2.1 (2022-06-23)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘soDemo/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘soDemo’ version ‘1.0’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘soDemo’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking compilation flags in Makevars ... OK
* checking for GNU extensions in Makefiles ... OK
* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
* checking use of PKG_*FLAGS in Makefiles ... OK
* checking compilation flags used ... OK
* checking compiled code ... OK
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
Running ‘tinytest.R’
OK
* checking PDF version of manual ... OK
* DONE
Status: OK
edd#rob:~/git/stackoverflow/73405262(master)$
I put the tarball here if you want to take it from there.
I have been working on an R package for work for sometime and have been making updates and installing it to my machine for over a year. For some reason, last month, I can no longer build to source, binary and hence I cannot install and restart.
When I choose the document option:
==> devtools::document(roclets = c('rd', 'collate', 'namespace'))
i Updating LICHospitalR documentation
i Loading LICHospitalR
Writing NAMESPACE
Writing NAMESPACE
Documentation completed
It runs successfully.
Now when I click Install and Restart
==> Rcmd.exe INSTALL --no-multiarch --with-keep.source LICHospitalR
* installing to library 'C:/Users/bha485/Documents/R/win-library/4.1'
* installing *binary* package 'LICHospitalR' ...
cp: unknown option -- )
Try '/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/bha485/Documents/R/win-library/4.1/LICHospitalR'
* restoring previous 'C:/Users/bha485/Documents/R/win-library/4.1/LICHospitalR'
Exited with status 1.
Also when I do a check:
==> devtools::check()
i Updating LICHospitalR documentation
i Loading LICHospitalR
Registered S3 method overwritten by 'tune':
method from
required_pkgs.model_spec parsnip
Registered S3 methods overwritten by 'stars':
method from
st_bbox.SpatRaster sf
st_crs.SpatRaster sf
Writing NAMESPACE
Writing NAMESPACE
-- Building ------------------------------------- LICHospitalR --
Setting env vars:
* CFLAGS : -Wall -pedantic -fdiagnostics-color=always
* CXXFLAGS : -Wall -pedantic -fdiagnostics-color=always
* CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
-----------------------------------------------------------------
v checking for file 'C:\Users\bha485\Desktop\LICHospitalR/DESCRIPTION' ...
- preparing 'LICHospitalR': (3.3s)
v checking DESCRIPTION meta-information ...
v checking whether 'INDEX' is up-to-date (929ms)
- installing the package to build vignettes
-----------------------------------
- installing *binary* package 'LICHospitalR' ...
cp: unknown option -- )
Try '/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
- removing 'C:/Users/bha485/AppData/Local/Temp/RtmpQX3Cq3/Rinst1e246e7f3ee6/LICHospitalR'
-----------------------------------
ERROR: package installation failed
Error: System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr:
E> * checking for file 'C:\Users\bha485\Desktop\LICHospitalR/DESCRIPTION' ... OK
E> * preparing 'LICHospitalR':
E> * checking DESCRIPTION meta-information ... OK
E> * checking whether 'INDEX' is up-to-date ... OK
E> * installing the package to build vignettes
E> -----------------------------------
E> * installing *binary* package 'LICHospitalR' ...
E> cp: unknown option -- )
E> Try '/usr/bin/cp --help' for more information.
E> ERROR: installing binary package failed
E> * removing 'C:/Users/bha485/AppData/Local/Temp/RtmpQX3Cq3/Rinst1e246e7f3ee6/LICHospitalR'
E> -----------------------------------
E> ERROR: package installation failed
Stack trace:
1. devtools::check(, check_dir = dirname(getwd()))
2. withr::with_envvar(pkgbuild::compiler_flags(FALSE), action = "pre ...
3. base:::force(code)
4. pkgbuild::build(pkg$path, tempdir(), args = build_args, quiet = q ...
5. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options ...
6. base:::force(code)
7. pkgbuild:::rcmd_build_tools(options$cmd, c(options$path, options$ ...
8. pkgbuild:::with_build_tools(callr::rcmd_safe(..., env = env, ...
9. withr::with_path(rtools_path(), code)
10. base:::force(code)
11. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, ...
12. callr:::run_r(options)
13. base:::with(options, with_envvar(env, do.call(processx::run, ...
14. base:::with.default(options, with_envvar(env, do.call(processx::r ...
15. base:::eval(substitute(expr), data, enclos = parent.frame())
16. base:::eval(substitute(expr), data, enclos = parent.frame())
17. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args ...
18. base:::force(code)
19. base:::do.call(processx::run, c(list(bin, args = real_cmdargs, ...
20. (function (command = NULL, args = character(), error_on_status = TRUE, ...
21. throw(new_process_error(res, call = sys.call(), echo = echo, ...
x System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr:
E> * checking for file 'C:\Users\bha485\Desktop\LICHospitalR/DESCRIPTION' ... OK
E> * preparing 'LICHospitalR':
E> * checking DESCRIPTION meta-information ... OK
E> * checking whether 'INDEX' is up-to-date ... OK
E> * installing the package to build vignettes
E> -----------------------------------
E> * installing *binary* package 'LICHospitalR' ...
E> cp: unknown option -- )
E> Try '/usr/bin/cp --help' for more information.
E> ERROR: installing binary package failed
E> * removing 'C:/Users/bha485/AppData/Local/Temp/RtmpQX3Cq3/Rinst1e246e7f3ee6/LICHospitalR'
E> -----------------------------------
E> ERROR: package installation failed
Execution halted
Exited with status 1.
Session Info:
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0
>
I really do not know where to go from here, should I file this as an issue on the github rstudio/rstudio? Or is there another avenue I can take.
UPDATE
GitHub of Project
Two related questions:
1. How does one install R and selected packages in the configuration.nix?
2. How does one add packages not only from CRAN but also from Gitub or at least locally stored?
In the wiki you will find instructions like these to install R packages. https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/r.section.md . Have it working when using nix-shell but I'm stuck while trying to do the installation from configuration.nix.
Regarding building R packages and I have found this example regarding building packages:
let
pkgs = import <nixpkgs> {};
buildRPackage = import <nixpkgs/pkgs/development/r-modules/generic-builder.nix> pkgs.R;
in
with pkgs.rPackages;
{
foobar = buildRPackage {
name = "your-package-name-1.0";
src = ./.;
propagatedBuildInputs = [/* required dependencies go here */];
};
}
The command "nix-build . -A foobar" would then compile it.
But would like to run all from configuration.nix in order to the machine configuration in one place.
Ok, with the help of Bulats pointer above I managed to find a solution. A complete example was found here: https://github.com/NixOS/nixpkgs/issues/44290
For future reference here is one way of adding r packages both from CRAN and Github inline in configuration.nix:
environment.systemPackages = with pkgs;
[(pkgs.rWrapper.override {
packages = with pkgs.rPackages; let
llr = buildRPackage {
name = "llr";
src = pkgs.fetchFromGitHub {
owner = "dirkschumacher";
repo = "llr";
rev = "0a654d469af231e9017e1100f00df47bae212b2c";
sha256 = "0ks96m35z73nf2sb1cb8d7dv8hq8dcmxxhc61dnllrwxqq9m36lr";};
propagatedBuildInputs = [ rlang knitr];
nativeBuildInputs = [ rlang knitr ];};
in [knitr
rlang
llr
tidyverse
## the rest of your R packages here
devtools];})
pkgs.postgresql
pkgs.isync
pkgs.msmtp
pkgs.notmuch
gnupg
## the rest of your Nixos packages (derivations) here
];
I have recently started exploring R programming and have a very trivial doubt. I want to write a function which would try to load the required packages and install the same in case its not installed already.
I have written it using if else logic. My question is will it be more efficient if I use tryCatch()? Is there any other advantage than the ability to handle errors as it is not important to handle errors in this context.
Below is the code I am currently using:
Inst.Pkgs=function(){
if (!require(tm))
{install.packages("tm")
require(tm)}
if (!require(SnowballC))
{install.packages("SnowballC")
require(SnowballC)}
if (!require(wordcloud))
{install.packages("wordcloud")
require(wordcloud)}
if (!require(RWeka))
{install.packages("RWeka")
require(RWeka)}
if (!require(qdap))
{install.packages("qdap")
require(qdap)}
if (!require(timeDate))
{install.packages("timeDate")
require(timeDate)}
if (!require(googleVis))
{install.packages("googleVis")
require(googleVis)}
if (!require(rCharts))
{
if (!require(downloader))
{install.packages("downloader")
require(downloader)}
download("https://github.com/ramnathv/rCharts/archive/master.tar.gz", "rCharts.tar.gz")
install.packages("rCharts.tar.gz", repos = NULL, type = "source")
require(rCharts)
}
}
You can check at once and install missing packages.
# Definition of function out, the opposite of in
"%out%" <- function(x, table) match(x, table, nomatch = 0) == 0
# Storing target packages
pkgs <- c("tm", "SnowballC", "wordcloud", "RWeka", "qdap",
"timeDate", "googleVis")
# Finding which target packages are already installed using
# function installed.packages(). Names of packages are stored
# in the first column
idx <- pkgs %out% as.vector(installed.packages()[,1])
# Installing missing target packages
install.packages(pkgs[idx])
We can in fact use tryCatch for this. If the program tries to load a library that is not installed, it will throw an error - an error that can be caught and resolved with a function called by tryCatch().
Here's how I would do it:
needed_libs <- c("tm", "SnowballC", "wordcloud", "RWeka", "qdap", "timeDate", "googleVis")
install_missing <- function(lib){install.packages(lib,repos="https://cran.r-project.org/", dependencies = TRUE); library(lib, character.only = TRUE)}
for (lib in needed_libs) tryCatch(library(lib, character.only=TRUE), error = function(e) install_missing(lib))
This will install the missing packages and load the required libraries, as requested in the OP.
I am currently building a package in RStudio that uses Rcpp. I have defined the following .cpp file, which works with Rcpp::sourceCpp.
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::interfaces(r, cpp)]]
#include <Rcpp.h>
#include <unordered_set>
using namespace Rcpp;
// [[Rcpp::export]]
std::unordered_set<int> traverse_cor(NumericMatrix x, float maxcor) {
std::unordered_set<int> elements;
int ncol = x.ncol();
for(int i = 0; i < ncol; i++) {
for(int j = 0; j < ncol; j++) {
if(i < j) {
if(x(i, j) > maxcor && x(i, j) < 1){
elements.insert(i + 1);
}
}
}
}
return elements;
}
I am following the directions from here and here. Next I call Rcpp::compileAttributes(). This produces the following files:
src/RcppExports.cpp
R/RcppExports.R
inst/include/mypackage.h
inst/include/mypackage_RcppExports.h
The generated mypackage_RcppExports.h file looks as follows:
// This file was generated by Rcpp::compileAttributes
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#ifndef __gwassim_RcppExports_h__
#define __gwassim_RcppExports_h__
#include <Rcpp.h>
namespace gwassim {
using namespace Rcpp;
namespace {
void validateSignature(const char* sig) {
Rcpp::Function require = Rcpp::Environment::base_env()["require"];
require("gwassim", Rcpp::Named("quietly") = true);
typedef int(*Ptr_validate)(const char*);
static Ptr_validate p_validate = (Ptr_validate)
R_GetCCallable("gwassim", "gwassim_RcppExport_validate");
if (!p_validate(sig)) {
throw Rcpp::function_not_exported(
"C++ function with signature '" + std::string(sig) + "' not found in gwassim");
}
}
}
inline std::unordered_set<int> traverse_cor(NumericMatrix x, float maxcor) {
typedef SEXP(*Ptr_traverse_cor)(SEXP,SEXP);
static Ptr_traverse_cor p_traverse_cor = NULL;
if (p_traverse_cor == NULL) {
validateSignature("std::unordered_set<int>(*traverse_cor)(NumericMatrix,float)");
p_traverse_cor = (Ptr_traverse_cor)R_GetCCallable("gwassim", "gwassim_traverse_cor");
}
RObject __result;
{
RNGScope __rngScope;
__result = p_traverse_cor(Rcpp::wrap(x), Rcpp::wrap(maxcor));
}
if (__result.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
if (__result.inherits("try-error"))
throw Rcpp::exception(as<std::string>(__result).c_str());
return Rcpp::as<std::unordered_set<int> >(__result);
}
}
#endif // __gwassim_RcppExports_h__
After attempting to build and reload the package, I receive the following errors (1):
../inst/include/gwassim_RcppExports.h:27:12: error: 'unordered_set' in
namespace 'std' does not name a type
And (2)
RcppExports.cpp:12:1: error: 'unordered_set' in namespace 'std' does
not name a type
I have limited C++ experience, but my sense is that these errors occur due to #include <unordered_set> being omitted. How do I get these automatically generated files to have the correct headers?
My sessionInfo is the following:
Session info ----------------------------------------------------------------------
setting value
version R version 3.1.0 (2014-04-10)
system x86_64, mingw32
ui RStudio (0.99.235)
language (EN)
collate English_United States.1252
tz America/New_York
Packages --------------------------------------------------------------------------
package * version date source
devtools 1.7.0.9000 2015-02-11 Github (hadley/devtools#9415a8a)
digest * 0.6.4 2013-12-03 CRAN (R 3.1.0)
memoise * 0.2.1 2014-04-22 CRAN (R 3.1.0)
mvtnorm 1.0-2 2014-12-18 CRAN (R 3.1.2)
Rcpp 0.11.4 2015-01-24 CRAN (R 3.1.2)
roxygen2 * 4.1.0 2014-12-13 CRAN (R 3.1.2)
rstudioapi * 0.2 2014-12-31 CRAN (R 3.1.2)
stringr * 0.6.2 2012-12-06 CRAN (R 3.0.0)
And my version of g++ is 4.6.3, as included in the RTools package for Windows. I have enabled C++11 features with the following:
Sys.setenv("PKG_CXXFLAGS"="-std=c++0x").
That is a finicky one. I think you want Section 3.5.2 of the Rcpp Attributes vignette and this trick:
The Package.h file does nothing other than include the
Package_RcppExports.h header. This is done so that package
authors can replace the Package.h header with a custom one
and still be able to include the automatically generated exports
(details on doing this are provided in the next section).
In passing, I think I also convinced you to create a package rather than to rely just on sourceCpp() :)
Edit: Doh!! I overlooked the part that
std::unordered_set<int> traverse_cor(NumericMatrix x, float maxcor)
is probably not an automatically wrappable function. You may need to convert your set into a vector (or list or ...) to get one of the types that matches naturally into R.