sr:runresult
sr:runresult R-expression
Evaluates the given R expression and reports the result. rs:runresult
attempts to convert from R data types to NetLogo data types.
Numbers, strings, and booleans convert as you would expect, except for outliers like Infinity and NaN which will be converted into the strings ‘Inf’ and ‘NaN’, respectively.
R vectors and R lists will be converted to NetLogo lists. NA values will be converted into the string ‘NA’.
R matrices will be flattened into one-dimensional lists using column-major order. If you want to convert a matrix into a list of lists before sending it to NetLogo, use the R asplit
command. To convert into a list of column lists, use asplit(<matrix>, 1)
; for a list of row lists, use asplit(<matrix>, 2)
.
An R DataFrame will be converted into a list of lists, where the first item in each sublist is the name of the column and the second item is a list containing all that row data. For example, the first 6 rows of the iris
dataset will be converted into NetLogo like so:
[
["Sepal.Length" [5.1 4.9 4.7 4.6 5 5.4]]
["Sepal.Width" [3.5 3 3.2 3.1 3.6 3.9]]
["Petal.Length" [1.4 1.4 1.3 1.5 1.4 1.7]]
["Petal.Width" [0.2 0.2 0.2 0.2 0.2 0.4]]
["Species" ["setosa" "setosa" "setosa" "setosa" "setosa" "setosa"]]
]
Other objects will be converted to a string representation if possible and and may throw an error if not.
Take me to the full Simple R Extension Dictionary