File: ExportRSingle.htm

package info (click to toggle)
cain 1.10+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,856 kB
  • sloc: cpp: 49,612; python: 14,988; xml: 11,654; ansic: 3,644; makefile: 133; sh: 2
file content (83 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

<html>
<head>
<title>Single Trajectory</title>
</head>
<body>
<h1>Single Trajectory</h1>

<p>
Open the file <tt>examples/cain/WilkinsonSMfSB/ch06-lv.xml</tt>,
which models the Lotka-Volterra system.
Generate a single trajectory using the defined model and method
by clicking the launch button <img src="launch.png">.
Next click the export button <img src="filesave.png">&nbsp;
in the simulation output panel.
This will bring up the export configuration window shown below.
You may read the 
<a href="VisualizationExporting.htm">Exporting Data</a> section 
in the
<a href="Visualization.htm">Visualization and Analysis</a> chapter
for an explanation of its features.
</p>

<p align="center">
<!--Resize to fit the window contents before capturing.-->
<img src="ExportR/Single/Configuration.png">
</p>

<p>
Click the export button and enter &quot;lv&quot; in the file dialog to
create the data file <tt>lv.csv</tt>. Launch R and set the working 
directory to where you have saved the data file. For myself, this
is &quot;Development/cain&quot;. Read the CSV (Comma Separated Values)
file and have a look at the first few lines.
</p>

<pre>
&gt; setwd('Development/cain')
&gt; lv.df &lt;- read.csv('lv.csv')
&gt; head(lv.df)
  Time Prey Predator
1    0   50      100
2    1   93       79
3    2  159       84
4    3  255      132
5    4  269      283
6    5  141      434
</pre>

<p>
To make a time series data structure, we drop the first column.
We could simply define the starting time to be zero and the time 
increment to be one. However, to show the general method, below
we have used the time values in first column. By default,
plotting the time series data will yield separate plots.
</p>

<pre>
&gt; lv.ts &lt;- ts(lv.df[,-1], start=lv.df[1,1], deltat=lv.df[2,1]-lv.df[1,1])
&gt; plot(lv.ts)
</pre>


<p align="center">
<!--Save as 8x6. Export to PNG and then resize to 4x3.-->
<img src="ExportR/Single/lvMultiple.png">
</p>

<p>
You can also put the species together in a single plot.
</p>

<pre>
&gt; plot(lv.ts, plot.style='single')
</pre>

<p align="center">
<img src="ExportR/Single/lvSingle.png">
</p>


</body>
</html>