MyNixOS website logo
Description

A Code Converter from the Matlab/Octave Language to R.

Transferring over a code base from Matlab to R is often a repetitive and inefficient use of time. This package provides a translator for Matlab / Octave code into R code. It does some syntax changes, but most of the heavy lifting is in the function changes since the languages are so similar. Options for different data structures and the functions that can be changed are given. The Matlab code should be mostly in adherence to the standard style guide but some effort has been made to accommodate different number of spaces and other small syntax issues. This will not make the code more R friendly and may not even run afterwards. However, the rudimentary syntax, base function and data structure conversion is done quickly so that the maintainer can focus on changes to the design structure.

matconv

A Utility to Convert Matlab / Octave Code into R Code

The time and headaches that come from migrating legacy code into a new language keeps many from transitioning to R. There are methods to call Matlab code in R, or call Matlab directly in R. There isn't a good translator for the code it self. There are times when you choose the wrong coding language for a project or when you want to migrate a large code base where doing the small differences between languages takes too much time and energy. This program tries to make that move easier by doing the rudimentary things automatically. R and Matlab are so similar in scope and purpose that such a translator can do more than change syntax but also migrate compatible base functions and choose new data structures for some of the variables.

The code consists of a wrapper function, 'mat2r' to do the various parts of the translation. It does syntax changes automatically, but the function and data converters have to be passed to it directly. These are made with the functions "makeFuncMaps", "makeDataMap" and "makeSliceMap" and are passed to the main driver as a list. This makes it so that a translation can be as precise and customized to each individual projects needs.

Installation

install.packages("matconv")

For the most up to date version you can go to the development version using:

install.packages("devtools")
devtools::install_github("sidjai/matconv")

For a detailed look into how to use this package you can look at the vignettes:

library("rmarkdown")
rmarkdown::render(paste(system.file(package="matconv"), "vignettes/basicSyntax.rmd", sep="/"))
rmarkdown::render(paste(system.file(package="matconv"), "vignettes/functionCalls.rmd", sep="/"))
rmarkdown::render(paste(system.file(package="matconv"), "vignettes/overallUse.rmd", sep="/"))
Metadata

Version

0.4.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows