matlab2r {matlab2r} | R Documentation |
Convert Matlab function to R
Description
Performs basic syntax conversion from a Matlab function file to R
Usage
matlab2r(
input,
output = "diff",
improve_formatting = TRUE,
change_assignment = TRUE,
append = FALSE,
restyle = !improve_formatting,
skip_lines = NULL
)
Arguments
input |
file path or character string containing MATLAB code |
output |
can be "asis", "clean", "save" or "diff" |
improve_formatting |
if |
change_assignment |
if |
append |
if |
restyle |
if |
skip_lines |
vector of lines to be skipped. These will be commented out and tagged as TODO, instead. |
Value
text converted to R, printed to screen or replacing input file
Note
This function is intended to expedite the process of converting a Matlab function to R by making common replacements. It does not have the immediate goal of outputting a ready-to-use function. In other words, after using this function you should go back to it and make minor changes.
It is also advised to do a dry-run with output = "clean"
and only switching
to output = "save"
when you are confident that no important code will be
lost (for shorter functions, a careful visual inspection should suffice).
Author(s)
Waldir Leoncio
Examples
matlab_script <- system.file("extdata", "matlabDemo.m", package = "matlab2r")
matlab2r(matlab_script)
matlab2r(matlab_script, output = "clean")