# Analysis of community ecology data in R

David Zelený

### Site Tools

en:cycle_and_function

# Differences

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

 en:cycle_and_function [2013/11/13 04:09]127.0.0.1 external edit en:cycle_and_function [2017/10/11 20:36] (current) Both sides previous revision Previous revision 2015/02/15 22:09 David Zelený [Use of loop] 2014/12/06 20:03 David Zelený 2013/11/13 04:09 external edit2013/04/01 14:54 David Zelený 2013/04/01 14:54 David Zelený 2013/04/01 14:37 David Zelený created Next revision Previous revision 2015/02/15 22:09 David Zelený [Use of loop] 2014/12/06 20:03 David Zelený 2013/11/13 04:09 external edit2013/04/01 14:54 David Zelený 2013/04/01 14:54 David Zelený 2013/04/01 14:37 David Zelený created Line 1: Line 1: ====== Creating a loop and function ====== ====== Creating a loop and function ====== + FIXME + How to create a loop, which will repeat given action x-times, and how to define the function will be demonstrated on creating the script for //random walk//. How to create a loop, which will repeat given action x-times, and how to define the function will be demonstrated on creating the script for //random walk//. Line 28: Line 30: ​ - will randomly select one value from the vector, containing numbers ''​-1''​ and ''​1'',​ in this case value ''​-1''​. You just made the first step to the right. + will randomly select one value from the vector, containing numbers ''​-1'' ​ and ''​1'',​ in this case value ''​-1''​. You just made the first step to the right. Vector ''​steps.rw''​ contains only zeroes: Vector ''​steps.rw''​ contains only zeroes: Line 44: Line 46: ​ - You may have realized that in function ''​sample'',​ there are no names of arguments (''​x''​ and ''​size''​) - they are not needed, until you write the values for arguments in the defined order (what is this order you can check in the help to the function ''​sample'',​ which you call typing ''?​sample''​). + You may have realized that in function ''​sample'',​ there are no names of arguments (''​x'' ​ and ''​size''​) - they are not needed, until you write the values for arguments in the defined order (what is this order you can check in the help to the function ''​sample'',​ which you call typing ''?​sample''​). Further steps can be defined in the following way: Further steps can be defined in the following way: Line 87: Line 89: ​ - The figure is not here, because for ear run the figure looks different. Argument ''​x''​ in the function ''​plot''​ contains values you want to draw. Theoretically,​ the arguments should be two, ''​x''​ and ''​y'',​ i.e. the values for x and y axis; if the ''​y''​ argument is missing, the function proceeds as following: the values of ''​x''​ argument are drawn on vertical axis, and horizontal axis is represented by the order of values in the vector. + The figure is not here, because for each run the figure looks different. Argument ''​x''​ in the function ''​plot''​ contains values you want to draw. Theoretically,​ the arguments should be two, ''​x'' ​ and ''​y'',​ i.e. the values for x and y axis; if the ''​y''​ argument is missing, the function proceeds as following: the values of ''​x''​ argument are drawn on vertical axis, and horizontal axis is represented by the order of values in the vector. FIXME FIXME