Giter Site home page Giter Site logo

locallib's Introduction

locallib

virtualenv for R.

Overview

This package looks to replicate some of the functionality of virtualenv for R. Underneath the covers there's really just one thing going on: prepending a local library to the library trees within which packages are looked for. The user is trusted to determine whether they want to include non-base packages in their global library(s).

Getting started

Until locallib is available on CRAN, use devtools to install it:

if (!require("devtools")) {
  install.packages("devtools")
}

devtools::install_github("Mullefa/locallib")

To create your first project which utilises a local library, open R in a new project directory and load locallib:

library(locallib)

You will get a lot of warnings about packages being installed globally. If you want to remove these, so that all non-base packages are installed at the project level (recommended):

clean_global_libs()

Now you just have to create a local library and use it:

create_local_lib()
use_local_lib()

At this point, any installed packages will be installed into the local library (file path ./library). To get a snapshot of your local library:

freeze()

This will create a file specifying all the packages used in the project and their versions (file path ./pkgs.yaml). This is useful as now it is easy to replicate the local library:

thaw()

One last thing to mention is a pattern I use whenever starting a new project with its own local library. With a R console opened in the new project directory:

create_.Rprofile()

Now restart R. The created .Rprofile will activate the local library whenever the user is in interactive mode.

Use with multidplyr

The function cluster_use_local_lib() can be used to activate the locally activated local lib on each of the remote nodes e.g.

library(locallib)
library(dplyr)
library(multidplyr)

get_default_cluster %>% cluster_use_local_lib

Examples

Check out geohash-vis.

locallib's People

Contributors

mullefa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

steromano

locallib's Issues

default local lib?

The fact that locallib requires you to install all your non-base packages locally is good for production but can be a bit annoying sometimes for exploratory stuff. What if I just want to try out some package (maybe with a bunch of dependencies) but not necessarily inside a project?
What I'm currently doing is having "generic" local lib, which is basically the equivalent of my global library, and if I'm not working on a specific project I just activate that one.
I was wondering if it could make sense to have an environment variable pointing to your generic library, and have use_local_lib default to that if it doesn't find a local library in the working directory.
Or alternatively providing a use_global_lib function of some sort.
Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.