Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
calculate_r_expression [2018/09/03 14:29]
francisco [R Script Outputs]
calculate_r_expression [2018/09/18 14:13]
francisco [Tables / Lookup Tables]
Line 99: Line 99:
   * A [[Lookup Table Type|Lookup Table]] requires //2// number vectors, one for the "​Keys"​ and another for the "​Values"​. Both vectors must have the same number of elements.   * A [[Lookup Table Type|Lookup Table]] requires //2// number vectors, one for the "​Keys"​ and another for the "​Values"​. Both vectors must have the same number of elements.
  
-  * The ''​outputTable''​ function requires a table, that can be construct ​with [[http://​www.r-tutor.com/​r-introduction/​data-frame | data.frame]] R function. ​Tt has an optional ​parameter tooto put how many Key columns the table has, from the leftmost column, the default value of it is 1.+  * The ''​outputTable''​ function requires a table, that can be constructed ​with [[http://​www.r-tutor.com/​r-introduction/​data-frame | data.frame]] R function. ​There is another parameter that is optional ​with default value 1and it means how many Key columns the table has, from the leftmost column.
 <note important>​Notice the use of the stringAsFactors = FALSE flag. This flag prevents R from converting the passed strings to Factors(numbers).</​note>​ <note important>​Notice the use of the stringAsFactors = FALSE flag. This flag prevents R from converting the passed strings to Factors(numbers).</​note>​
  
Line 108: Line 108:
 === Lookup Tables === === Lookup Tables ===
  
-Lookup Tables are transferred to R as a List with two columns, "Keys" and "Values".+Lookup Tables are transferred to R as a List with two columns, "Key" and "Value".
  
 Each column can be individually accessed by using the ''​$''​ operator, for example: Each column can be individually accessed by using the ''​$''​ operator, for example:
  
-  * ''​t1$Keys[ 1 ]''​ will access the first key of the Lookup Table ''​t1''​. ​+  * ''​t1$Key[ 1 ]''​ will access the first key of the Lookup Table ''​t1''​. ​
    
-  * ''​t2$Values[ 2 ]''​ will access the second value of the Lookup Table ''​t2''​+  * ''​t2$Value[ 2 ]''​ will access the second value of the Lookup Table ''​t2''​
  
 === Tables === === Tables ===
Line 128: Line 128:
 Expression: Expression:
 <code rsplus> <code rsplus>
-for ( i in 1:length( t1$Values ​) ) { +for ( i in 1:length( t1$Value ) ) { 
-  tempValue <- t1$Values[ i ]; +  tempValue <- t1$Value[ i ]; 
-  t1$Values[ i ] = tempValue * tempValue;+  t1$Value[ i ] = tempValue * tempValue;
 } }
  
-outputLookupTable( "​poweredTable",​ t1$Keys, t1$Values ​);+outputLookupTable( "​poweredTable",​ t1$Key, t1$Value );
 </​code>​ </​code>​
  
Line 142: Line 142:
 Expression: Expression:
 <code rsplus> <code rsplus>
-tableMean <- mean( t1$Values ​);+tableMean <- mean( t1$Value );
 print( paste( "Mean is", tableMean ) ); print( paste( "Mean is", tableMean ) );
 outputDouble( "​mean",​ tableMean ); outputDouble( "​mean",​ tableMean );
 </​code>​ </​code>​
  
-Noticed the ''​print()''​ statement? Dinamica EGO's Message Log will show output messages from the R script (as Result'​s).+Noticed the ''​print()''​ statement? Dinamica EGO's Message Log will show output messages from the R script (as Result'​s).<note warning>​If the Message Log level is Unconditional,​ the messages will not be printed.</​note>​
  
 ==== Plot passed Lookup Table to an image on the path specified by passed String ==== ==== Plot passed Lookup Table to an image on the path specified by passed String ====