import matlab with R Script, no output..
hi,
I want to loop trough a directory with matlab files in it. I do it with R.matlab package in a R script.
I want to import every file and output it as an Example set (data table) and pass it to a collection operator.
however, I am not able to get an Example set of the data table as output... why is this?
my process looks like:
<?xml version="1.0" encoding="UTF-8"?><process version="7.3.001">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="7.3.001" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="loop_files" compatibility="7.3.001" expanded="true" height="82" name="Loop Files" width="90" x="45" y="34">
<parameter key="directory" value="C:\Users\Admin\Desktop\matlab"/>
<process expanded="true">
<operator activated="true" breakpoints="after" class="r_scripting:execute_r" compatibility="7.2.000" expanded="true" height="82" name="Execute R" width="90" x="179" y="34">
<parameter key="script" value="# rm_main is a mandatory function, # the number of arguments has to be the number of input ports (can be none) rm_main = function(data) { 	if("xlsx" %in% rownames(installed.packages()) == FALSE) {install.packages("xlsx")} 	if("R.matlab" %in% rownames(installed.packages()) == FALSE) {install.packages("R.matlab")} 	library(xlsx) 	library(R.matlab) 	 	setwd("C:/Users/Admin/Desktop") # read in your matlab file 	matfile <- readMat(data) 	# write into Excel file 	excelfile <- write.xlsx(matfile, "PathToExcelFile.xlsx", sheetName="1", col.names=TRUE, row.names = TRUE, append = FALSE, showNA=TRUE) 	o <- as.data.frame(matfile) # connect 2 output ports to see the results print(head(o)) return(o) } "/>
</operator>
<operator activated="true" class="collect" compatibility="7.3.001" expanded="true" height="82" name="Collect" width="90" x="313" y="34"/>
<connect from_port="file object" to_op="Execute R" to_port="input 1"/>
<connect from_op="Execute R" from_port="output 1" to_op="Collect" to_port="input 1"/>
<connect from_op="Collect" from_port="collection" to_port="out 1"/>
<portSpacing port="source_file object" spacing="0"/>
<portSpacing port="source_in 1" spacing="0"/>
<portSpacing port="sink_out 1" spacing="0"/>
<portSpacing port="sink_out 2" spacing="0"/>
</process>
</operator>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
</operator>
</process>
maybe I could also write it as excel file back on some folder and pass the path as a macro to some read excel operator afterwards? and then just read the excel file as usual with the "read excel" operator and the macro...?
but I prefer the direct way as an example set... anybody got an idea why the output does not work?
my 2nd question is:
Is there any way to avoid loading the libraries once again every time the loop is executed? I would like to load them once for all the loops...