mat2r: mat2r

Description Usage Arguments Value Examples

View source: R/mat2r.R

Description

The top level driver function to call the converting functions and handle the input and output.

Usage

1
2
3
4
5
6
7
mat2r(
  inMat,
  pathOutR = "",
  funcConverters = NULL,
  dataConverters = NULL,
  verbose = 1
)

Arguments

inMat

A file path with the input Matlab / Octave code to be converted or a character vector of the code that needs to be converted

pathOutR

A file path with the desired output file location

funcConverters

A list of function converters that the user wants to use in this conversion made by makeFuncMaps

dataConverters

A list of data converters that the user wants to use in this conversion made by makeSliceMap or makeDataMap

verbose

A number indicating the amount of messages that should be outputed.

0

No messages

1

A summary report of what happened in the conversion

2

The final code as a message as well as the summary report

Value

A list containing the original code (named matCode) and the converted code (named rCode).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
matIn <- c("function [ dat ] = xlsReadPretty(varargin)", 
 "  didThing = 1*3;",
 "  dat = didThing / 3;",
 "end")
 mat2r(matIn, verbose = 0)$rCode

# "xlsReadPretty <- function(...){" 
# "\tvarargin <- list(...)"
# "  didThing <- 1*3"
# "  dat <- didThing / 3"
#"\treturn(dat)"
#"}"

Example output

[1] "xlsReadPretty <- function(...){" "\tvarargin <- list(...)"        
[3] "  didThing <- 1*3"               "  dat <- didThing / 3"          
[5] "\treturn(dat)"                   "}"                              

matconv documentation built on May 13, 2021, 9:06 a.m.