diff --git a/R/matlab2r.R b/R/matlab2r.R index e041634..f69dcb8 100644 --- a/R/matlab2r.R +++ b/R/matlab2r.R @@ -4,6 +4,7 @@ #' @param saveOutput if `TRUE`, `filename` is overwritten. Defaults to `FALSE` #' @return text converted to R, printed to screen or replacing input file #' @author Waldir Leoncio +#' @importFrom utils write.table #' @export matlab2r <- function(filename, saveOutput = FALSE) { # Verification @@ -21,7 +22,7 @@ matlab2r <- function(filename, saveOutput = FALSE) { txt <- gsub("for (.+)=(.+)", "for (\\1 in \\2) {", txt) txt <- gsub("end", "}", txt) txt <- gsub("(.),(\\S)", "\\1, \\2", txt) - # TODO: replace forms like (:,:) with [, ] + # TODO: replace forms like (:,:) with [, ] if they come before <- # TODO: add argument to skip some of these rules txt <- gsub("if (.+)", "if (\\1) {", txt) # FIXME: paste comments after { txt <- gsub("else$", "} else {", txt) diff --git a/man/matlab2r.Rd b/man/matlab2r.Rd new file mode 100644 index 0000000..e5a3f9e --- /dev/null +++ b/man/matlab2r.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/matlab2r.R +\name{matlab2r} +\alias{matlab2r} +\title{Convert Matlab function to R} +\usage{ +matlab2r(filename, saveOutput = FALSE) +} +\arguments{ +\item{filename}{name of the file} + +\item{saveOutput}{if `TRUE`, `filename` is overwritten. Defaults to `FALSE`} +} +\value{ +text converted to R, printed to screen or replacing input file +} +\description{ +Performs basic syntax conversion from Matlab to R +} +\author{ +Waldir Leoncio +}