makeFuncMaps: Turn dictionary lines into functions that map matlab to R...

Description Usage Arguments Details Value Examples

View source: R/convFunctionCalls.R

Description

Turn dictionary lines into functions that map matlab to R function calls

Usage

1
makeFuncMaps(addDict = NULL, pathDict = "")

Arguments

addDict

An optional character vector with manufactored lines

pathDict

The path to a text file with the dictionary lines written to it

Details

The output of the individual maps consits of the actual map for the given matlab arguments as a vector and a list of flags included in the dictionary. The argMap itself is a list of potential functions that could be used if a some flags are detected in the dictionary line. A more expansive look at the different dictionaries that could be used can be seen in the base dictionary at "extdata/HiebelerDict.txt" or in the vignette "vignettes/functionCalls.rmd". It returns a list with the R version of the arguments with a left parentheisis.

Value

a list of functions to convert the arguments of a matlab function. It comes with the names of matlab functions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
funcMap <- makeFuncMaps("trace: sum, diag(%1)")
funcMap[['trace']]$argMap[[1]]("matThing")
#$rargs
# "sum(diag(matThing)"

funcMap <- makeFuncMaps("mod: , 1 %% 2")
funcMap[['mod']]$argMap[[1]](c(4, 2))
#$rargs
# "(4, %%, 2"

test1 <- "mat"
test2 <- c("mat", "2")

funcMap <- makeFuncMaps(c("size--if 1:dim, 1", "size--if 2: ,dim(%1)[%2]"))
rightConv <- funcMap$size$flags$multSwitch(test1)
funcMap$size$argMap[[rightConv]](test1)
#$rargs
 "dim(mat"
 
rightConv <- funcMap$size$flags$multSwitch(test2)
funcMap$size$argMap[[rightConv]](test2)
#$rargs
 "dim(mat)[2]"

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