sr:set-agent-data-frame
sr:set-agent-data-frame r-variable-name agents agent-variable-name sr:set-agent-data-frame r-variable-name agents agent-variable-name1 agent-variable-name2...
Creates a new data frame in R with the given variable name. The columns will have the names of the NetLogo agent variables used and each row will be one agent’s data. If you want multiple agent variables make sure to surround the command in parenthesis.
clear-all
sr:setup
create-turtles 2
ask turtle 0 [ set color red set xcor 5]
ask turtle 1 [ set color blue set xcor -5]
(sr:set-agent-data-frame "turtles_data_frame" turtles "who" "color" "xcor" "hidden?")
sr:run "print(typeof(turtles_data_frame))"
;; [1] "list"
sr:run "print(is.data.frame(turtles_data_frame))"
;; [1] TRUE
sr:run "print(turtles_data_frame)"
;; who color xcor hidden?
;; 1 0 15 5 FALSE
;; 2 1 105 -5 FALSE
Take me to the full Simple R Extension Dictionary