R

17 posts

Package update – Plotting multi-objective linear/integer programming models in R

R package gMOIP has been updated to version 1.3.0 and now can plot 3D models too. The package can make 2D and 3D plots of the polytope of a linear programming (LP), integer linear programming (ILP) model, or mixed integer linear programming (MILP) model with 2 or 3 variables, including integer points, ranges and iso profit curve. Moreover you can also make a plot of the bi-objective criterion space and the non-dominated (Pareto) set for bi-objective LP/ILP/MILP programming models. Figures can be prepared for LaTeX and can automatically be transformed to TikZ using package tikzDevice.

Multi-Objective Optimization Repository (MOrepo)

The past weeks we have created Multi-Objective Optimization Repository (MOrepo) which is a response to the needs of researchers from the MCDM society to access multi-objective (MO) optimization instances. The repository contains instances, results, generators etc. for different MO problems and is continuously updated. The repository can be used as a test set for testing new algorithms, validating existing results and for reproducibility. All researchers within MO optimization are welcome to contribute. For more information see https://github.com/MCDMSociety/MOrepo.

Using LocalSolver to solve VRP problems

The last days I have been playing a bit with LocalSolver and tried to model various vehicle routing problems (VRP). LocalSolver is a heuristic solver based on a heuristic search approach combining different optimization techniques. It includes a math modeling language (LSP) and there is a package so that it can be used from R. You need to download and install LocalSolver (I used v7.0) and get an academic license from their webpage.

Plotting IP and MO-IP models in R

I recent released a small package gMOIP which can make 2D plots of linear and integer programming models (LP/IP). With the package you can make plots of the feasible region (or solution space) of an LP, visualize the integer points inside the region and the iso profit curve. Moreover, can also make a plot of a bi-objective criterion space and the non-dominated (Pareto) set. Figures are prepared for LaTeX and can automatically be transformed to TikZ using tikzDevice.

Animation of wind using Shiny

I have played a bit with Shiny the last days. Let us try to create an shiny web application which show a map and add a layer with wind directions and wind speed. First we need weather data for a given latitude and longitude. We will use the API from forecast.io to retrieve data. Your will need an API key for using the service. We define functions to retrieve the data

Distance matrix calculations in R

Many models in Operations Research needs a distance matrix between nodes in a network. If the distance matrix is based on road distances it can be found using R. Let us try to compute the distances between a set for zip codes in Denmark. First we load all zip codes for Jutland in Denmark:

Publishing R markdown to WordPress

In some cases it may be useful to write a WordPress post in R Markdown and afterwards publish it to my blog. This can be done using the RWordPress package. First we setup a link to my blog: if (!require(‘RWordPress’)) install.packages(‘RWordPress’, repos = ‘http://www.omegahat.org/R’, type = ‘source’) library(RWordPress) options(WordPressLogin = c(<your username> = ‘<your password>’), WordPressURL = ‘https://www.research.relund.dk/wp/xmlrpc.php’) Next the post is written in a Rmd file and afterwards published to WordPress: id<-knit2wp(‘RWordPress_post.Rmd’, title = ‘Publishing R markdown to WordPress’, categories = c(‘R’), publish=F ) Now the post with id is a draft on my blog and I can have a look at it before publishing it. If I want to update the post I do: knit2wp(‘RWordPress_post.Rmd’, title = ‘Publishing R markdown to WordPress’, postid=id, action=’editPost’, categories = c(‘R’), publish = F ) To highlight the above code I use the WP Code Highlight.js plugin. If you use other syntax highlight […]

Migrating from svn (R-forge) to git (GitHub)

I recent migrated my R package mdp from my R-forge svn repo to GitHub. Do the following: Create an empty folder mdp and open a shell and import the svn to git (I only imported the pkg sub-folder svn+ssh://relund@svn.r-forge.r-project.org/svnroot/mdp/pkg) git svn clone svn+ssh://relund@svn.r-forge.r-project.org/svnroot/mdp/pkg . # import the svn git branch -a # info, should show a git-svn remote branch git svn info # show svn details (also URL) Now add your local repo to GitHub. First, create an empty GitHub repo and next run from the shell: git remote add origin https://github.com/relund/mdp.git git push -u origin master The first line tells Git that your local repo has a remote version on GitHub, and calls it “origin”. The second line pushes all your current work to that repo. Now you have a local Git repo and 2 remote repos (one at GitHub and one at R-forge). You want to use GitHub as […]

Using RStudio together with Git and GitHub on Windows

I have started to use Git and GitHub together with RStudio. Git is a distributed version control system which is very useful when doing reproducible research. It is a good way to handle programming/coding. Moreover, Git (via GitHub) allows groups of people to work on the same documents (often code) at the same time, and without stepping on each other’s toes. RStudio is an excellent integrated development environment built specifically for R.