<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=136.159.197.186</id>
	<title>IdeaWazaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=136.159.197.186"/>
	<link rel="alternate" type="text/html" href="https://ideawaza.com/wiki/Special:Contributions/136.159.197.186"/>
	<updated>2026-09-29T22:25:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://ideawaza.com/index.php?title=How_to_use_R/Tutorials/Introduction&amp;diff=38037</id>
		<title>How to use R/Tutorials/Introduction</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=How_to_use_R/Tutorials/Introduction&amp;diff=38037"/>
		<updated>2006-08-15T18:52:21Z</updated>

		<summary type="html">&lt;p&gt;136.159.197.186: /* Loading and plotting data with R */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;[[R programming language|R]]&#039;&#039;&#039; is both a programming language, and a software environment for statistical computing. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Loading and plotting data with R ==&lt;br /&gt;
This tutorial demonstrates how to plot data loaded from files in R.&lt;br /&gt;
&lt;br /&gt;
* Given the data file &#039;&#039;data.txt&#039;&#039; located at &#039;&#039;&amp;lt;path&amp;gt;&#039;&#039;:&lt;br /&gt;
 1970    45    63&lt;br /&gt;
 1980    52    59&lt;br /&gt;
 1990    59    52&lt;br /&gt;
 2000    63    45&lt;br /&gt;
&lt;br /&gt;
* This data can easilty be loaded into R using the following commands:&lt;br /&gt;
 setwd(&amp;quot;&amp;lt;path&amp;gt;&amp;quot;)                # change working directory&lt;br /&gt;
 data &amp;lt;- read.table(&amp;quot;data.txt&amp;quot;)  # load data&lt;br /&gt;
&lt;br /&gt;
* Plotting can then be performed as follows:&lt;br /&gt;
 # Setup empty plot window&lt;br /&gt;
 plot(0, type = &amp;quot;n&amp;quot;, main = &amp;quot;Plot Title&amp;quot;, xlab = &amp;quot;X axis&amp;quot;, ylab = &amp;quot;Y axis&amp;quot;, xlim = c(1970,2000), ylim = c(0,100))&lt;br /&gt;
 grid()                              # add grid&lt;br /&gt;
 lines(data[,1], data[,2], lty = 1)  # draw first dataset&lt;br /&gt;
 lines(data[,1], data[,3], lty = 2)  # draw second dataset&lt;br /&gt;
 legend(&amp;quot;topright&amp;quot;, c(&amp;quot;first dataset&amp;quot;, &amp;quot;second dataset&amp;quot;), lty = c(1, 2) )&lt;br /&gt;
&lt;br /&gt;
* Export of the plot to &#039;&#039;pdf&#039;&#039; is easilty performed by adding &#039;&#039;pdf(&amp;quot;filename.pdf&amp;quot;)&#039;&#039; prior to the plotting, and &#039;&#039;dev.off()&#039;&#039; after the plotting.&lt;br /&gt;
* Export to &#039;&#039;png&#039;&#039; can simmilarly be performed by calling &#039;&#039;png(&amp;quot;filename.png&amp;quot;)&#039;&#039; prior to the plotting, and &#039;&#039;dev.off()&#039;&#039; after the plotting. &#039;&#039;png(&amp;quot;r_plot.png&amp;quot;, width = 420, height = 340)&#039;&#039; will, for example yield the following figure:&lt;br /&gt;
[[Image:R_plot.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{stub}}&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>136.159.197.186</name></author>
	</entry>
</feed>