My primary goal is to extract metadata of an article using the title and journal name. To do so, rmetadata package is useful according to the blog https://ropensci.org/blog/2013/03/15/r-metadata/. However, I'm unable to install the package using the install_github() function. Any help? Thanks!
The repo is now archived at https://github.com/ropensci-archive/rmetadata
It does install though, try remotes::install_github("ropensci-archive/rmetadata")
However, that package is no longer maintained. You probably want to use rcrossref, see the docs at https://docs.ropensci.org/rcrossref/. e.g.,
install.packages("rcrossref")
res = cr_works(flq = c(`query.container-title` = 'Ecology',
`query.bibliographic` = 'An assessment of statistical methods for
nonindependent data in ecological meta-analyses'))
See the Crossref API docs http://api.crossref.org/swagger-ui/index.html#/Works/get_works as well
Related
I'm actually evaluate different solution to enhance/explore reproductibility in my R/Python scientific workflow : data with reproductible analysis (plot, analysis) and paper.
There is, as you know, two big linux flavours offer some solutions : Nix and Guix
In nix, the way commonly described to develop with R is, for example, using rWrapper and rPackages :
pkgs.rWrapper.override{ packages = with pkgs.rPackages; [tidyverse rmarkdown]; };
My problem is (not so...) simple, like Python, R is well known to be a nightmare in term of reproducibility, even at middle term. For fun, you could try to run a ggplot2 code from 2 years with a recent version of R...
In order to propose a flake that produce the same result from the same data for a scientific paper, i'm interested to fix in derivation the version of R and the version of R packages used to compute analysis or plot.
{
description = "Generate R result from simulation";
inputs = {
nixpkgs.url = "nixpkgs/nixos-20.09";
utils.url = "github:numtide/flake-utils";
};
outputs = {self, nixpkgs, utils, mach-nix } : (utils.lib.eachDefaultSystem
(system :
let
pkgs = nixpkgs.legacyPackages.${system};
REnv = pkgs.rWrapper.override{ packages = with pkgs.rPackages; [tidyverse rmarkdown]; };
buildRScripts = { stdenv, fetch,... }: stdenv.mkDerivation {
name = "myscript";
src = self;
nativeBuildInputs = [ REnv ];
dontBuild = true;
buildInputs = [ pkgs.pandoc pkgs.unzip ];
installPhase=''
mkdir $out
cd $out
${REnv}/bin/Rscript -e 'rmarkdown::render("test.Rmd")
'';
in {
defaultPackage = self.packages.${system}.buildRScripts;
}
));}
For example, how could i define more precisly that i want to use, to compile my test.Rmd, only the tidyverse 1.3.1 with R 4.1.O ? Even in 5 years ?
I found that Guix show different available packages/versions of R and tidyverse :
http://data.guix.gnu.org/repository/1/branch/master/package/r-tidyverse
Version needed by tidyverse.1.3.1 are clearly presented :
http://data.guix.gnu.org/gnu/store/31rwnjq3map2njx1518vsxpwbvy7xx2j-r-tidyverse-1.3.1.drv
With rPackages in Nix i search a way to achieve something similar, ie. a way to refer explicitly to version of R or R packages into derivation, but i didn't found it.
With rPackages here nix developper already offering a great fundation, but perhaps we need more ...
How we could, collectively achieve a better reproducibility on R packages with Nix ? I'm interested by any ideas ?
Perhaps we could fetch sources of packages directly from the cran archive and compile it ? For example with tidyverse :
https://cran.r-project.org/web/packages/tidyverse/index.html,
https://cran.r-project.org/src/contrib/Archive/tidyverse/ ?
Ps : i know that Nix and Guix are each partners with https://archive.softwareheritage.org/, a great way to archive and call cran package :
https://guix.gnu.org/fr/blog/2019/connecting-reproducible-deployment-to-a-long-term-source-code-archive/
https://www.tweag.io/blog/2020-06-18-software-heritage/
Ps : answer could also be added to https://nixos.wiki/wiki/R
Update 1
After discussion with some great people on nix discord, i understand that nix doesn't need version because flake.nix + flake.lock store hash (see nix flake metadata) that link my build and download with a very specific commit on nixpkgs.
But that don't solve :
the problem of the tar.gz sources linked/needed by this packages declared at this very specific commit by RPackages ? I suppose software heritage will help on this point ?
the common problem of incompatibility between some R version, and R version of packages. For example, you write a code with R 3.0.0 and tidyverse 1.2.3, you update your R version because some other packages need an update and only works with dependency available with R 3.2.0, but ahum, tidyverse 1.2.3 don't exist for R 3.2.0 ... Fixing version and access to old tar.gz resolve part of this problem i suppose.
How we define something like this using nix ?
Update 2
It seems someone build an unofficial index to help people searching old version of package Ex with tidyverse : https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=r-tidyverse
Thanks #dram for link and discussion on this.
I am brand new to this so please forgive my inexperience...I'm trying to learn.
I'm attempting to install an R package called "Doublet Finder" using the specified code given on the Github site.
When I do this, I get this error immediately:
Error in rbind(info, getNamespaceInfo(env, "S3methods")) :
number of columns of matrices must match (see arg 2)
Being new to R, I'm not sure what this error means and when I google this something similar comes up and the individual removed and re-installed ALL of their libraries...that seems crazy. Does anyone have advice on what this could be, how to fix it, or why the package won't install?
Your problem seems to be fairly similar to this one. It might be the case that the dependencies (packages that Doublet Finder relies on) are outdated. What you can try is to follow these steps to uninstall and reinstall all packages with the hope that by updating packages there isn't a version mismatch.
This code is copied from the website above:
ip <- as.data.frame(installed.packages(lib.loc = .libPaths()[1]),
stringsAsFactors = FALSE)
head(ip)
str(ip)
path.lib <- unique(ip$LibPath)
# create a vector with all the names of the packages you want to remove
pkgs.to.remove <- ip[,1]
head(pkgs.to.remove)
str(pkgs.to.remove)
sapply(pkgs.to.remove, remove.packages, lib = path.lib)
sapply(pkgs.to.remove, install.packages, lib = path.lib)
I am trying to find out time series anomaly detection in which i need to install new R packages. In this i m following https://github.com/business-science/anomalize site. In this i needed to install 2 packages: tidyverse and anomalize.
can anyone help me on installing package mentioned above as I am getting
error "package or namespace load failed for tidyverse"
Also while adding zip of tidyverse and anomalize do I need to add any other packages and dependencies in that as I am adding only those 2 packages thinking there r no other dependencies I needed for those 2?
you can see in code that I created R_Package.zip and put tidyverse.zip and anomalize.zip in that that
dataset1 <- maml.mapInputPort(1)
data.set <- data.frame(installed.packages())
#install.packages(“src/R_Package/tidyverse_1.2.1.zip”, lib = “.”,
repos = NULL, verbose = TRUE);
#library(tidyverse, lib.loc=”.”, verbose=TRUE);
install.packages("src/tidyverse.zip",lib=".",repos=NULL,verbose=TRUE)
library(R_package, lib.loc = ".", verbose=TRUE);
install.packages("src/anomalize.zip",lib=".",repos=NULL,verbose=TRUE)
library(R_package, lib.loc = ".", verbose=TRUE);
#success <- library("tidyverse", lib.loc = ".",
logical.return = TRUE, verbose = TRUE)
#library(tidyverse)
maml.mapOutputPort("dataset1");
Regarding the error message, notice that it may take some time for the installed packages to become actually available; quoting from Adding R Packages In Azure ML blog post:
Note: In one instance, we ran into an issue where the package was not
loaded into the workspace immediately. We had to wait about half an
hour before we could use the package. You may be running into this
issue as well if you see a message that looks something like this
and you’ve used the above method to check which packages are in your
workspace and the package in question appears on that list. If this is
the case, we suggest waiting a bit before running your experiment
again.
AFAIK yes, you also need to add the package dependencies; the SO thread Install R Packages in Azure ML contains some useful hints.
Suppose that
the version of R I have installed is 3.3.1;
my environment variable $R_LIBS_USER is set to $HOME/my/R_lib/%V; and
I have a directory $HOME/my/R_lib/3.3.1 containing a large number of packages I've installed over time.
Now I want to upgrade my version of R, to 3.4.1, say.
I'm looking for a convenient way to install a new collection of packages under the new directory $HOME/my/R_lib/3.4.1 that is the "version-3.4.1-equivalent" of the library I currently have under $HOME/my/R_lib/3.3.1.
(IOW, I'm looking for a functionality similar to what one can do with Python's pip installer's "freeze" option, which, essentially, produces the input one would have to give the installer in the future to reproduce the current installation.)
You can use function installed.packages for that purpose. Namely:
installed.packages(lib.loc = "$HOME/my/R_lib/3.3.1")
The returned object contains a lot of informations (most fields from each package DESCRIPTION file) but the names of the packages are in the first column. So something like the following should do the trick:
inst <- installed.packages(lib.loc = "$HOME/my/R_lib/3.3.1")
install.packages(inst[,1], lib="$HOME/my/R_lib/3.4.1", dependencies=FALSE)
To answer the additional question in the comments:
If your old library contained packages from other sources than CRAN, you will have to do some gymnastic based on the content of the DESCRIPTION files, and thus will depend on how well the package author documented it.
Argument field in installed.packages allows you to select some additional fields from those files. Fields of interest to determine the source of a package are fields Repository, URL and Maintainer. Here are some ideas on how to split them apart:
CRAN vs non-CRAN:
inst <- installed.packages(lib.loc = "$HOME/my/R_lib/3.3.1",
fields=c("URL","Repository","Maintainer"))
inst <- as.data.frame(inst, row.names=NA, stringsAsFactors=FALSE)
cran <- inst[inst$Repository%in%"CRAN",]
non_cran <- inst[!inst$Repository%in%"CRAN" & !inst$Priority%in%"base",]
Bioconductor packages:
bioc <- inst[grepl("Bioconductor",inst$Maintainer),]
source("https://bioconductor.org/biocLite.R")
biocLite(pkgs=bioc$Packages)
Github packages:
git <- non_cran[grepl("github", non_cran$URL),]
install.packages("devtools")
library(devtools)
for(i in seq(nrow(git))){
install_github(repo=gsub("http://github.com/","",git$URL[i]))
}
I'm using R version 3.0.2 and have installed the package tm. Previously, I also loaded a package called tm.plugin.tags. To get a measure of whether a text corpus was positive or negative I used the following approach:
library('tm')
library('tm.plugin.tags')
pos <- tm_tag_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), tm_get_tags("Positiv"))
tm.plugin.tags seems to be no longer available for R. This was based on the following classification system http://www.wjh.harvard.edu/~inquirer/homecat.htm and I'm wondering if there is any other package or approach that I can use to achieve a similar result.
I have emailed the package maintainer of tm so I will post an update here once/if I receive a response.
You can install tm.plugin.tags using the following command
install.packages("tm.plugin.tags", repos = "http://datacube.wu.ac.at", type = "source")
This installs without any problem
Thanks
Cheers