<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rense Nieuwenhuis &#187; Academic Software</title>
	<atom:link href="http://www.rensenieuwenhuis.nl/tag/academic-software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rensenieuwenhuis.nl</link>
	<description>&#34;The extra-ordinary lies within the curve of normality&#34;</description>
	<lastBuildDate>Thu, 12 Mar 2026 14:58:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>Reading .PDF articles on iPhone</title>
		<link>http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/</link>
		<comments>http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 10:00:39 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.PDF]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[reading]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=806</guid>
		<description><![CDATA[I promised to write some on the use of Apple&#8217;s iPhone in an academic setting. Now, I have found one that allows you to read .PDF articles when on the road, provided that they are ...]]></description>
				<content:encoded><![CDATA[<p>I promised to write some on the use of Apple&#8217;s iPhone in an academic setting. Now, I have found one that allows you to read .PDF articles when on the road, provided that they are uploaded to MobileMe. It&#8217;s a free application, and it will serve many reading-needs untill existing software such as BibDesk or Papers will incorporate iPhone utilities, which of course would be really nice. For now, we will have to rely on MobileFiles.<br />
<span id="more-806"></span><br />
MobileFiles is freely available from the App store and coonects to your MobileMe account easily. Just enter your username and password, and that&#8217;s it. The interface is clean and initially shows your online iDisk, as well as files that are stored locally on your iPhone. Using a structure similar to the Finder, it is easy to find your files. Once found, you can store them on your iPhone, or open them directly, provided that the iPhone can read them. And yes, the iPhone can rezd .PDF files.<br />

<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0001/'><img width="150" height="150" src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0001.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0001" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0002/'><img width="150" height="150" src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0002.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0002" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0003/'><img width="150" height="150" src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0003.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0003" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0005/'><img width="150" height="150" src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0005.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0005" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0006/'><img width="150" height="150" src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0006.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0006" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0007/'><img width="150" height="150" src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0007.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0007" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0008/'><img width="150" height="150" src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0008.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0008" /></a>
<a href='http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/img_0010/'><img width="150" height="150" src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/11/img_0010.png?resize=150%2C150" class="attachment-thumbnail" alt="img_0010" /></a>
<br />
I use BibDesk to automatically store my articles, and I <a href="http://www.rensenieuwenhuis.nl/archive/sync-bibdesk-papers-to-mobileme-idisk/">previously explained how to sync those with MobileMe</a>. So, when I go the the folder in which I store my articles, I can easily read them, wherever I am. Sure, heavy reading on such a small screen is not very comfortable, but it does well when a quick reference is what you need. All the usual benefits of the iPhone interface are available: you can pinch to zoom in or out, when you rotate the device the article&#8217;s orientation also changes, and you can rotate single pages easily, again with the multitouch interface. Scrolling large articles can be a bit slow, especially concerning older articles which are basically scanned versions of the paper edition. The only thing missing is the ability to take notes. For that, I guess we&#8217;ll have to wait for the iPhone version of Skim.<br />
<!--adsense--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/reading-pdf-articles-on-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>R-Sessions 27: Text Editors for R: Textmate</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-27/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-27/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 10:14:33 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[Textmate]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=686</guid>
		<description><![CDATA[R-Project works best with a good text editor that is well integrated with R-Project. This edition of the R-Sessions will focus on <a href="http://macromates.com/">TextMate</a>, a paid application marketed as 'The Missing Editor for Mac OS X'. 

Designed explicitly for use by programmers on Mac OS X, TextMate makes a promising first impression. The interface looks very clean, text is rendered perfectly, and syntax colouring is provided for quite a large number of programming languages. Also, the colouring of the syntax looks very nice, by the use of light colours that don't interfere with reading the text.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p>R-Project works best with a good text editor that is well integrated with R-Project. This edition of the R-Sessions will focus on <a href="http://macromates.com/">TextMate</a>, a paid application marketed as &#8216;The Missing Editor for Mac OS X&#8217;. </p>
<p>Designed explicitly for use by programmers on Mac OS X, TextMate makes a promising first impression. The interface looks very clean, text is rendered perfectly, and syntax colouring is provided for quite a large number of programming languages. Also, the colouring of the syntax looks very nice, by the use of light colours that don&#8217;t interfere with reading the text.</p>
<p><img src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2008/10/textmate.tiff" alt="" title="textmate" class="alignnone size-full wp-image-687" /><br />
<span id="more-686"></span><br />
R-Project integration is not standard, but is installed rather easily. It requires a little tinkering in the Terminal, but I don&#8217;t expect many users of R-Project to scare away from that. TextMate uses so-called Bundles to provide integration with and definition of many programming languages. The bundles also provide short templates of often used functions. A list of bundles is made available <a href="http://macromates.com/svn/Bundles/trunk/Bundles/">here</a> (amongst which one for R-Project, and instruction on how to install TextMate bundles is found <a href="http://manual.macromates.com/en/bundles#getting_more_bundles">here</a>.</p>
<p>The R Bundle sends the whole file, or just a selection, to the R prompt swiftly. It also sends a command to set the R Working Directory to the path where the executed syntax is located. I fail to understand why, though, and found it sometimes a little annoying when scrolling back though my output and finding the working directory set between almost every command. </p>
<p>TextMate is full of nice, little details. Row numbering, marking specific rows for future attention, manually setting the number of spaces for a tab, adjusting the way syntax is coloured, and tabbed viewing of multiple files: it&#8217;s all there, and it is all executed properly. Also, loops and other nested syntax (such as function definitions, which is often used when working with R), can be collapsed, so that only the first row remains visible. Using this clears up complex syntax in a breeze. </p>
<p>The most important feature to me, however, was using the Project Drawer. As the image below shows, this sums up several of the files you&#8217;re currently working on. The collection of files can be saved as Projects, so you can continue working on them at later stages. The Project-file only contains references to the actual files, so the text-files will always remain accessible by other applications. More importantly, you can even manage the physical files from within TextMate: when you delete a file from the Project Drawer, you can choose to delete only the reference to the file, or to move the actual file to the Trash, as well. Of course, new files can be created from within TextMate as well. </p>
<p><img src="http://www.rensenieuwenhuis.nl/wp-content/uploads/2008/10/textmate-drawer.tiff" alt="" title="textmate-drawer" class="alignnone size-full wp-image-688" /></p>
<p>Overall, TextMate is a very solid text editor. It integrates with R-Project reasonably well, colours the syntax much better than the internal editor of R-Project, and provides strong functionality in the form of project management. By using extension bundles, it can do much more than syntax editing for R-Project, but when using it for that purpose only, I find the price (â‚¬48.75 at the time of writing) a little too steep. Also, the closed source of the software may not appeal to some users of the open-source R-Project. Therefore, the next R-Sessions will focus on some open-source and / or free alternatives, that appear to be at least as good.</p>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/R-forum/">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-27/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>R-Sessions 11: Tables</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-11-tables/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-11-tables/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 10:00:27 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=425</guid>
		<description><![CDATA[The one most often used function in the analysis of statistical data is the creation of tables. This edition of the R-Sessions describes the use of several functions to do some nifty cross-tabulations. And more.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p><!--adsense--><br />
The one most often used function in the analysis of statistical data is the creation of tables. This edition of the R-Sessions describes the use of several functions to do some nifty cross-tabulations. And more.</p>
<h2>TAPPLY</h2>
<p>The function TAPPLY can be used to perform calculations on table-marginals. Different functions can be used, such as MEAN, SUM, VAR, SD, LENGTH (for frequency-tables). For example: <span id="more-425"></span></p>
<blockquote><p> x &lt;- c(0,1,2,3,4,5,6,7,8,9)<br />
y &lt;- c(1,1,1,1,1,1,2,2,2,2)<br />
tapply(x,y,mean)<br />
tapply(x,y,sum)<br />
tapply(x,y,var)<br />
tapply(x,y,length)</p></blockquote>
<pre>
&gt; x &lt;- c(0,1,2,3,4,5,6,7,8,9)
&gt; y &lt;- c(1,1,1,1,1,1,2,2,2,2)
&gt; tapply(x,y,mean)
  1     2
2.5   7.5
&gt; tapply(x,y,sum)
 1  2
15 30
&gt; tapply(x,y,var)
       1        2
3.500000 1.666667
&gt; tapply(x,y,length)
1 2
6 4
&gt;</pre>
<h2>FTABLE</h2>
<p>More elaborate frequency tables can be created with the FTABLE-function. For example:</p>
<blockquote><p> x &lt;- c(0,1,2,3,4,5,6,7,8,9)<br />
y &lt;- c(1,1,1,1,1,1,2,2,2,2)<br />
z &lt;- c(1,1,1,2,2,2,2,2,1,1)<br />
ftable(x,y,z)</p></blockquote>
<pre>
&gt; x &lt;- c(0,1,2,3,4,5,6,7,8,9)
&gt; y &lt;- c(1,1,1,1,1,1,2,2,2,2)
&gt; z &lt;- c(1,1,1,2,2,2,2,2,1,1)
&gt; ftable(x,y,z)
    z 1 2
x y
0 1   1 0
  2   0 0
1 1   1 0
  2   0 0
2 1   1 0
  2   0 0
3 1   0 1
  2   0 0
4 1   0 1
  2   0 0
5 1   0 1
  2   0 0
6 1   0 0
  2   0 1
7 1   0 0
  2   0 1
8 1   0 0
  2   1 0
9 1   0 0
  2   1 0</pre>
<p><i><br />
&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/R-forum/">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/basics/tables/">Find the original article embedded in the manual.</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-11-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 10: Conditionals</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-10-conditionals/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-10-conditionals/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 10:00:21 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=423</guid>
		<description><![CDATA[Conditionals, or logicals, are used to check vectors of data against conditions. In practice, this is used to select subsets of data or to recode values. In this edition of the R-Sessions, some of the fundamentals of conditionals are described.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p><!--adsense--> Conditionals, or logicals, are used to check vectors of data against conditions. In practice, this is used to select subsets of data or to recode values. Here, only some of the fundamentals of conditionals are described.</p>
<h2>Basics</h2>
<p>The general form of conditionals are two values, or two sets of values, and the condition to test against. Examples of such tests are &#8216;is larger than&#8217;, &#8216;equals&#8217;, and &#8216;is larger than&#8217;. In the example below the values &#8216;3&#8217; and &#8216;4&#8217; are tested using these three tests.</p>
<blockquote><p> 3 &gt; 4 3 == 4 3 &lt; 4</p></blockquote>
<p><span id="more-423"></span></p>
<pre>
&gt; 3 &gt; 4
[1] FALSE
&gt; 3 == 4
[1] FALSE
&gt; 3 &lt; 4
[1] TRUE</pre>
<h2>Numerical returns</h2>
<p>The output shown directly above makes clear that R-Project returns the values &#8216;TRUE&#8217; and &#8216;FALSE&#8217; to conditional tests. The results here are pretty straightforward: 3 is not larger than 4, therefore R returns FALSE. If you don&#8217;t desire TRUE or FALSE as response, but a numeric output, use the as.numeric() command which transforms the values to numerics, in this case &#8216;0&#8217; or &#8216;1&#8217;. This is shown below.</p>
<blockquote><p> as.numeric(3 &gt; 4) as.numeric(3 &lt; 4)</p></blockquote>
<pre>
&gt; as.numeric(3 &gt; 4)
[1] 0
&gt; as.numeric(3 &lt; 4)
[1] 1</pre>
<h2>Conditionals on vectors</h2>
<p>As on most functionality of R-project, vectors (or multiple values) can be used alongside single values, as is the case on conditionals. These can be used not only against single values, but against variables containing multiple values as well. This will result in a succession of tests, one for each value in the variable. The output is a vector of values, &#8216;TRUE&#8217; or &#8216;FALSE&#8217;.The examples below show two things: the subsequent values 1 to 10 are tested against the condition &#8216;is smaller than or equals 5&#8242;. It is shown as well that when these values are assigned to a variable (here: &#8216;x&#8217;), this variable can be tested against the same condition, giving exactly the same results.</p>
<blockquote><p> 1:10 1:10 &lt;= 5 x &lt;- 1:10 x &lt;= 5</p></blockquote>
<pre>
&gt; 1:10
 [1]  1  2  3  4  5  6  7  8  9 10
&gt; 1:10 &lt;= 5
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
&gt; x &lt;- 1:10
&gt; x == 5
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE</pre>
<h2>Conditionals and multiple tests</h2>
<p>More tests can be gathered into one conditional expression. For instance, building on the example above, the first row of the next example tests the values of variable &#8216;x&#8217; against being smaller than or equal to 4, <em>or</em> being larger than or equal to &#8216;6&#8217;. This results in &#8216;TRUE&#8217; for all the values, except for 5. Since the &#8216;|&#8217;-operator is used, only one of the set conditions need to be true. The second row of this example below tests the same values against two conditions as well, namely &#8216;equal to or larger than 4&#8242; and &#8216;equal to or smaller than 6&#8242;. since this time the &#8216;&amp;&#8217;-operator is used, both conditionals need to be true.</p>
<blockquote><p> x &lt;= 4 | x &gt;= 6 x &gt;= 4 &amp; x &lt;= 6</p></blockquote>
<pre>
&gt; x &lt;= 4 | x &gt;= 6
 [1]  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
&gt; x &gt;= 4 &amp; x &lt;= 6
 [1] FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE</pre>
<h2>Conditionals on character values</h2>
<p>In the example below, a string variable &#8216;gender&#8217; is constructed, containing the values &#8216;male&#8217; and &#8216;female&#8217;.  This is shown in the first two rows of the example below.</p>
<blockquote><p> gender &lt;- c(&#8220;male&#8221;,&#8221;female&#8221;,&#8221;female&#8221;,&#8221;male&#8221;,&#8221;male&#8221;,&#8221;male&#8221;,&#8221;female&#8221;) gender == &#8220;male&#8221;</p></blockquote>
<pre>
&gt; gender &lt;- c("male","female","female","male","male","male","female")
&gt; gender == "male"
[1]  TRUE FALSE FALSE  TRUE  TRUE  TRUE FALSE</pre>
<h2>Additional functions</h2>
<p>The last examples demonstrate two other functions using conditionals, using the same &#8216;gender&#8217; variable as above. The first is an additional way to get a numerical output of the same test as in the row above. The iselse() command has three arguments: the first is a conditional, the second is the desired output if the conditional is TRUE, the third is the output in case the result of the test is &#8216;FALSE&#8217;. The second example shows a way to obtain a list of which values match the condition tested against. In the output above, the second, third and last values are &#8216;female&#8217;. Using which() and the condition &#8220;== &#8216;male&#8217; &#8221; (equals &#8216;male&#8217;) returns the indices of the values in variable &#8216;gender&#8217; that equal &#8216;male&#8217;.</p>
<blockquote><p> ifelse(gender==&#8221;male&#8221;,0,1) which(gender==&#8221;male&#8221;)</p></blockquote>
<pre>
&gt; ifelse(gender=="male",0,1)
[1] 0 1 1 0 0 0 1
&gt; which(gender=="male")
[1] 1 4 5 6</pre>
<h2>Conditionals on missing values</h2>
<p>Missings values (&#8216;NA&#8217;) form a special case in many ways, such as when using conditionals. Normal conditionals cannot be used to find the missing values in a range of values, as is shown below.</p>
<blockquote><p> x &lt;- c(4,3,6,NA,4,3,NA) x == NA which(x == NA)  is.na(x) which(is.na(x))</p></blockquote>
<p>The last two rows of the syntax above show what can be done. The is.na() command tests whether a value or a vector of values is missing. It returns a vector of logicals (&#8216;TRUE&#8217; or &#8216;FALSE&#8217;), that indicates missing values with a &#8216;TRUE&#8217;. Nesting this command in the which() command described earlier enables us to find which of the values are missing. In this case, the fourth and the seventh values are missing.</p>
<pre>
&gt; x &lt;- c(4,3,6,NA,4,3,NA)
&gt; x == NA
[1] NA NA NA NA NA NA NA
&gt; which(x == NA)
integer(0)
&gt; is.na(x)
[1] FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE
&gt; which(is.na(x))
[1] 4 7</pre>
<p><i><br />
&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-10-conditionals">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/basics/conditionals/">Find the original article embedded in the manual.</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-10-conditionals/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>R-Sessions 09: Data Manipulation</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-09-data-manipulation/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-09-data-manipulation/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 10:00:39 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data-manipulation]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=421</guid>
		<description><![CDATA[Today's edition of R-Sessions deals with the manipulation of data that is stored R-Project. Building upon the previous R-Session, attention is paid to recoding of data, ordering, and finally the merging of several sets of data.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a><br />
<!--adsense--></p>
<p>Today&#8217;s edition of R-Sessions deals with the manipulation of data that is stored R-Project. Building upon the previous R-Session, attention is paid to recoding of data, ordering, and finally the merging of several sets of data.</p>
<p><span id="more-421"></span></p>
<h2>Recoding</h2>
<p>The most direct way to recode data in R-Project is using a combination of both indexing and <a href="http://www.rensenieuwenhuis.nl/r-project/manual/basics/conditionals/">conditionals as described elsewhere</a>. To exemplify this, a simply data.frame will be created below, containing variables indicating gender and monthly income in thousands of euros.</p>
<blockquote><p> gender &lt;- c(&#8220;male&#8221;, &#8220;female&#8221;, &#8220;female&#8221;, &#8220;male&#8221;, &#8220;male&#8221;, &#8220;male&#8221;, &#8220;female&#8221;)<br />
income &lt;- c(54, 34, 556, 57, 88, 856, 23)<br />
data &lt;- data.frame(gender, income)<br />
data</p></blockquote>
<pre>
&gt; gender &lt;- c("male", "female", "female", "male", "male", "male", "female")
&gt; income &lt;- c(54, 34, 556, 57, 88, 856, 23)
&gt; data &lt;- data.frame(gender, income)
&gt; data
  gender income
1   male     54
2 female     34
3 female    556
4   male     57
5   male     88
6   male    856
7 female     23</pre>
<p>Some of the values on the income variable seem exceptionally high. Let&#8217;s say we want to remove the two values on income higher than 500. In order to do so, we use the which() command, that reveals which of the values is greater than 500. Next, the result of this is used for indexing the data$income variable. Finally, the indicator for missing values, &#8216;NA&#8217; is assigned to the that selected values of the &#8216;income&#8217; variables. Obviously, we would normally only use the third line. The first two are shown here, to make clear exactly what is happening.</p>
<blockquote><p> which(data$income &gt; 500)<br />
data$income[data$income &gt; 500]<br />
data$income[data$income &gt; 500] &lt;- NA<br />
data</p></blockquote>
<pre>
&gt; which(data$income &gt; 500)
[1] 3 6
&gt; data$income[data$income &gt; 500]
[1] 556 856
&gt; data$income[data$income &gt; 500] &lt;- NA
&gt; data
  gender income
1   male     54
2 female     34
3 female     NA
4   male     57
5   male     88
6   male     NA
7 female     23</pre>
<p>Sometimes, it is desirable to replace missing values by the mean on the respective variables. That is what we are going to do here. Note, that in general practice it is not very sensible to impute two missing values using only five valid values. Nevertheless, we will proceed here.<br />
The first row of the example below shows that it is not automatically possible to calculate the mean of a variable that contains missing values. Since R-Project cannot compute a valid value, NA is returned. This is not what we want. Therefore, we instruct R-Project to remove missing values by adding na.rm=TRUE to the mean() command. Now, the right value is returned. When the same selection-techniques as above are used, an error will occur. Therefore, we need the is.na() command, that returns a vector of logicals (&#8216;TRUE&#8217; and &#8216;FALSE&#8217; ). Using is.na(), we can use the which() command to select the desired values on the income variable. To these, the calculated mean is assigned.</p>
<blockquote><p> mean(data$income)<br />
mean(data$income, na.rm=TRUE)<br />
data$income[which(is.na(data$income))] &lt;- mean(data$income, na.rm=TRUE)<br />
data</p></blockquote>
<pre>
&gt; mean(data$income)
[1] NA
&gt; mean(data$income, na.rm=TRUE)
[1] 51.2
&gt; data$income[which(is.na(data$income))] &lt;- mean(data$income, na.rm=TRUE)
&gt; data
  gender income
1   male   54.0
2 female   34.0
3 female   51.2
4   male   57.0
5   male   88.0
6   male   51.2
7 female   23.0</pre>
<h2>ORDER</h2>
<p>It is easy to sort a data-frame using the command order. Combined with indexing functions, it works as follows:</p>
<pre>
x &lt;- c(1,3,5,4,2)
y &lt;- c('a','b','c','d','e')
df &lt;- data.frame(x,y)

df
  x y
1 1 a
2 3 b
3 5 c
4 4 d
5 2 e

df[order(df$x),]
  x y
1 1 a
5 2 e
2 3 b
4 4 d
3 5 c</pre>
<h2>MERGE</h2>
<p>Merge puts multiple data.frames together, based on an identifier-variable which is unique or a combination of variables.</p>
<pre>
x &lt;- c(1,2,5,4,3)
y &lt;- c(1,2,3,4,5)
z &lt;- c('a','b','c','d','e')

df1 &lt;- data.frame(x,y)
df2 &lt;- data.frame(x,z)
df3 &lt;- merge(df1,df2,by=c("x"))

 df3
  x y z
1 1 1 a
2 2 2 b
3 3 5 e
4 4 4 d
5 5 3 c</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-09-data-manipulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 08: Getting Data into R</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-08-getting-data-into-r/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-08-getting-data-into-r/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 10:00:13 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=419</guid>
		<description><![CDATA[R-Project provides various ways to enter data. The most basic method is entering is manually, but this tends to get very tedious. An often more useful way is using the read.table command. It has some variants, as will be shown below. Another way of getting data into R is using the clipboard. The back-draw thereof is the loss of some control over the process. Finally, it will be described how data from SPSS can be read in directly.

Only basic ways of entering data into R are shown here. Much more is possible as other functions offer almost unlimited control. Here the emphasis will be on day-to-day usage.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p><!--adsense--></p>
<h2>Introduction</h2>
<p>Various ways are provided to enter data into R. The most basic method is entering is manually, but this tends to get very tedious. An often more useful way is using the read.table command. It has some variants, as will be shown below. Another way of getting data into R is using the clipboard. The back-draw thereof is the loss of some control over the process. Finally, it will be described how data from SPSS can be read in directly.</p>
<p>Only basic ways of entering data into R are shown here. Much more is possible as other functions offer almost unlimited control. Here the emphasis will be on day-to-day usage.</p>
<h2>Reading data from a file</h2>
<p>The most general of data-files are basically plain text-files that store the data. Rows generally represent the cases ( / respondents), although the top-row often will state the variable labels. The values these variables can take are written in columns, separated by some kind of indicator, often spaces, commas or tabs. Another variant is that there is no separating character. In that case all variables belonging to a single case are written in succession. Each variable then needs to have a specific number of character places defined, to be able to distinguish between variables. Variable labels are often left out on these type of files.<br />
<span id="more-419"></span></p>
<p>R is able to read all of the above-mentioned filetypes with the read.table() command, or its derivatives read.csv() and read.delim(). The exception to this are fixed-width files. These are loaded using the read.fwf() command, that uses different parameters. The derivatives of read.table() are basically the same command, but have different defaults. Because their use is so much convenience, these will be used here.</p>
<h2>Comma / Tab separated files</h2>
<p>As said, the most generic way of reading data is the read.table() command. When given only the filename as parameter, it treats a space as the separating character (so, beware on using spaces in variable labels) and assumes that there are no variable names on the first row of the data. The decimal sign is a &#8220;.&#8221;. This would lead to the first row of the syntax below, which assigns the contents of a datafile &#8220;filename&#8221; to the object data, which becomes a data.frame.</p>
<p>The read.csv() and the read.delim() commands are basically the same, but they have a different set of standard values to the parameters. Read.csv() is used for comma-separated files (such as, for instance, Microsoft Excell can export to). The syntax for read.csv() is very simple, as shown below. The read.table()-command can be used for the exact same purpose, by altering the parameters. The header=TRUE &#8211; parameter means that the first row of the file is now regarded as containing the variable names. The sep &#8211; parameter now indicates the comma &#8220;,&#8221; as the separating character.  fill=TRUE tells the function that if a row contains less columns than there are variables defined by the header row, the missing variables are still assigned to the data frame that results from this function. Those variables for these cases will have the value &#8216;NA&#8217; (missing). By dec=&#8221;.&#8221; the character used for decimal points is set to a point (to not interfere with the separating comma). In contrast with the read.table() function. the comment.char is disabled (set to nothing). Normally, if the comment.char is found in the data, no more data is read from the row that is was found on (after the sign, of course). In read.csv() this is disabled by default.</p>
<p>The last two rows of the syntax below shows the read.delim() command and the parameters needed to create the same functionality from read.table. The read.delim() function is used to read tab-delimited data. So, the sep-parameter is now set to &#8220;\t&#8221; by default. \t means tab. The other parameters are identical to those that read.csv() defaults to.</p>
<blockquote><p> data &lt;- read.table(&#8220;filename&#8221;)</p>
<p>data &lt;- read.csv(&#8220;filename&#8221;)<br />
data &lt;- read.table(&#8220;filename&#8221;, header = TRUE, sep = &#8220;,&#8221;, dec=&#8221;.&#8221;, fill = TRUE, comment.char=&#8221;&#8221;)</p>
<p>data &lt;- read.delim(&#8220;filename&#8221;)<br />
data &lt;- read.table(&#8220;filename&#8221;, header = TRUE, sep = &#8220;\t&#8221;, dec=&#8221;.&#8221;, fill = TRUE, comment.char=&#8221;&#8221;)</p></blockquote>
<h2>Variable labels</h2>
<p>Data that is read into a data.frame can be given variable names. For instance, if the above commands were used to read a data-file containing three variables, variable names can be assigned in several ways. Two ways will be described here: assigning them after the data is read or assigning them using the read.table() command.</p>
<blockquote><p>names(data) &lt;- c(&#8220;Age&#8221;,&#8221;Income&#8221;,&#8221;Gender&#8221;)<br />
data &lt;- read.table(&#8220;filename&#8221;, colnames=c(&#8220;Age&#8221;,&#8221;Income&#8221;,&#8221;Gender&#8221;))</p></blockquote>
<p>In the syntax above, the names() command is used to assign names to the columns of the data.frame (representing the variables). The names are given as strings (hence the apostrophes) and gathered using the c() command.</p>
<h2>Fixed width files</h2>
<p>When reading files in the &#8216;fixed width&#8217; format, we cannot rely on a single character that indicates the separations between variables. Instead, the read.fwf() function has a parameter by which we tell the function where to end a variable and start the next one. Just as with read.table(), a data.frame is returned. Variable labels are treated the same way as the previous mentioned</p>
<blockquote><p>data &lt;- read.fwf(&#8220;filename&#8221;, widths = c(2,5,1), colnames=c(&#8220;Age&#8221;, &#8220;Income&#8221;, &#8220;Gender&#8221;))<br />
data &lt;- read.fwf(&#8220;filename&#8221;, widths = c(-5,2,5,-2, 1), colnames=c(&#8220;Age&#8221;, &#8220;Income&#8221;, &#8220;Gender&#8221;))</p></blockquote>
<h2>Reading data from the clipboard</h2>
<blockquote><p>data &lt;- read.table(pipe(&#8220;pbpaste&#8221;))<br />
data &lt;- read.table(&#8220;clipboard&#8221;)</p></blockquote>
<p>read.table is used for read comma seperated files. read.delim is used for reading tab delimited files. read.table(pipe(&#8220;pbpaste&#8221;)) is used for reading data from the clipboard on mac. read.table(&#8220;clipboard&#8221;) is used for reading data from the clipboard on Windows. Instead of read.table(pipe(&#8220;pbpaste&#8221;)) you can use read.delim(pipe(&#8220;pbpaste&#8221;)) as well.</p>
<h2>Reading data from other statistical packages {foreign}</h2>
<blockquote><p>library(foreign)<br />
data &lt;-read.spss(&#8220;filename&#8221;)</p></blockquote>
<p>require(foreign) loads the foreign package, which contains the read.spss() function, which can read data as written by the SPSS software.</p>
<p><i></p>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-08-getting-data-into-r">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/basics/getting-data-into-r-2/">Find the original article embedded in the manual.</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-08-getting-data-into-r/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>R-Sessions 07: Data Structure</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-07-data-structure/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-07-data-structure/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 10:00:23 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=417</guid>
		<description><![CDATA[The way R-Project handles data differs from some mainstream statistical programs, such as SPSS. It can handle an unlimited number of data sets, as long as the memory of your computer can handle it. Often, the results of statistical tests or estimation-procedures are stored inside 'data-sets' as well. In order to be able to serve different needs, several different types of data-storage are available.

This edition of the R-Sessions will introduce some of the types of data-storage and shows how these objects are managed by R-Project.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p>The way R-Project handles data differs from some mainstream statistical programs, such as SPSS. It can handle an unlimited number of data sets, as long as the memory of your computer can handle it. Often, the results of statistical tests or estimation-procedures are stored inside &#8216;data-sets&#8217; as well. In order to be able to serve different needs, several different types of data-storage are available.</p>
<p>This paragraph will introduce some of the types of data-storage and shows how these objects are managed by R-Project.</p>
<h2>Single values and vectors</h2>
<p>As was already shown in a previous paragraph, data can easily be stored inside objects. This goes for single values and for ranges of values, called vectors. Below three variables values are created (x, y, and z) where x will contain a single numerical value, y contains three numerical values and z will contain two character values. This is done by using the c()-command that concatenates data. Finally, in the syntax below, it is shown that it is not possible to concatenate different types of data (i.e. numerical data and character data): when this is tried below, the numerical data are converted into character-data. </p>
<pre lang="rsplus" line="1">
 x <- 3
y <- c(4,5)
z <- c("one", "two")
x
y
z

c(x,y)
c(x,y,z)
</pre>
<p><code><br />
&gt; x &lt;- 3<br />
&gt; y &lt;- c(4,5)<br />
&gt; z &lt;- c("one", "two")<br />
&gt; x<br />
[1] 3<br />
&gt; y<br />
[1] 4 5<br />
&gt; z<br />
[1] "one" "two"<br />
&gt;<br />
&gt; c(x,y)<br />
[1] 3 4 5<br />
&gt; c(x,y,z)<br />
[1] "3"   "4"   "5"   "one" "two"<br />
</code></p>
<h2>Matrix</h2>
<p>Oftentimes, we want to store data in more than one dimension. This can be done with matrices, that have two dimensions. As with vectors, all the data inside a matrix have to be of the same type.</p>
<pre lang="rsplus" line="1">
a <- matrix(nrow=2, ncol=5)
b <- matrix(data=1:10, nrow=2, ncol=5, byrow=FALSE)
c <- matrix(data=1:10, nrow=2, ncol=5, byrow=TRUE)
d <- matrix(data=c("one", "two", "three", "four", "five", "six"), nrow=3, ncol=2, byrow=TRUE)
a
b
c
d
</pre>
<p>In the syntax above, four matrices are created and assigned to variables that were called 'a', 'b', 'c', and 'd'. The first matrix ('a') is created using the matrix() function. It is specified that this matrix will have two rows (nrow=2) and five columns (ncol=5). In the output we see the resulting matrix: all the data is missing, which is indicated by 'NA'.</p>
<p>The following two matrices have data assigned to it by the 'data=' parameter. To both matrices the values 1 to 10 are assigned, but in the first matrix 'byrow=FALSE' is specified and in the second 'byrow=TRUE'. This results in a different way the data is entered into the matrix (row-wise or column-wise), as can be seen below.</p>
<p>The last matrix shows us, that character values can be stored in matrices as well.<br />
<code><br />
&gt; a &lt;- matrix(nrow=2, ncol=5)<br />
&gt; b &lt;- matrix(data=1:10, nrow=2, ncol=5, byrow=FALSE)<br />
&gt; c &lt;- matrix(data=1:10, nrow=2, ncol=5, byrow=TRUE)<br />
&gt; d &lt;- matrix(data=c("one", "two", "three", "four", "five", "six"), nrow=3, ncol=2, byrow=TRUE)<br />
&gt; a<br />
     [,1] [,2] [,3] [,4] [,5]<br />
[1,]   NA   NA   NA   NA   NA<br />
[2,]   NA   NA   NA   NA   NA<br />
&gt; b<br />
     [,1] [,2] [,3] [,4] [,5]<br />
[1,]    1    3    5    7    9<br />
[2,]    2    4    6    8   10<br />
&gt; c<br />
     [,1] [,2] [,3] [,4] [,5]<br />
[1,]    1    2    3    4    5<br />
[2,]    6    7    8    9   10<br />
&gt; d<br />
     [,1]    [,2]<br />
[1,] "one"   "two"<br />
[2,] "three" "four"<br />
[3,] "five"  "six"<br />
</code></p>
<h2>data.frame</h2>
<p>In social sciences, we often use data-sets in which the rows represent respondents or participants of a survey and the columns represent different variables. This makes matrices less suitable, because we often have variables that store different types of data. This cannot be stored in a matrix.</p>
<p>For this purpose, R-Project has data.frames available. Data.frames can store multiple vectors that don't have to contain the same type of data. The columns are formed by the vectors entered to the data.frame() function that creates data.frames. All vectors need to be of the same length.</p>
<pre lang="rsplus" line="1">
p <- 1:5
q <- c("one", "two", "three", "four", "five")
r <- data.frame(p, q)
p
q
r
</pre>
<p>In the syntax above, the variables 'p' and 'q' are created with vectors of respectively numbers and characters. Then, these are combined in the data.frame called r. The output of the data.frame shows that the columns are named according to the variables entered and that the values in the rows correspond to the order of the values in the data-vectors.</p>
<p><code><br />
&gt; p &lt;- 1:5<br />
&gt; q &lt;- c("one", "two", "three", "four", "five")<br />
&gt; r &lt;- data.frame(p, q)<br />
&gt; p<br />
[1] 1 2 3 4 5<br />
&gt; q<br />
[1] "one"   "two"   "three" "four"  "five"<br />
&gt; r<br />
  p     q<br />
1 1   one<br />
2 2   two<br />
3 3 three<br />
4 4  four<br />
5 5  five<br />
</code></p>
<h2>Indexing</h2>
<p>Oftentimes, we don't want to use a full dataset for our analysis, or we want to select a single value from a range to be able to review or change it. This can be to see the values on a single variable or to see the scores on several variables for a specific respondent of a survey. This can be achieved by a technique called indexing variables.</p>
<p>Above, we've already created some variables of different types: a vector ('y'), a matrix ('c'), and a data.frame ('r'). In the first rows of the syntax below these variables are called for, so we can see what they look like.</p>
<pre lang="rsplus" line="1">
 y
c
r

y[2]
c[2,3]
r[3,1]
r[3,]
r$q
</pre>
<p>Then, they are indexed using straight brackets [ and ]. Since a vector has only one dimension, we place the number or index of the value we want to see between the brackets that are placed behind the name of the variable. In the syntax above, we want to see only the second value stored inside vector 'y'. In the output below we receive the value 5, which is correct.</p>
<p>A matrix has two dimensions and can be indexed using two values, instead of just one. For instance, let's sat we want to see the value on the second row on the third column stored in matrix 'c'. We used the index [2,3] to achieve this (first the row number, then the column number). Below we can see that this works out just fine.</p>
<p>Then the data.frame, which works almost the same as a matrix. First we want to see the value on the third row of the first column and index the data.frame 'r' by using [3,1]. The result is as expected. When we want to see all the values on a specific variable, we can address this variable by naming the data.frame in which it is stored, then a dollar-sign $ and finally the exact name of the variable. This is done on the next row of the syntax, where we call for the variable 'q' inside data.frame 'r'.</p>
<p>The same can be achieved for a single row of the data.frame, giving the scores on all columns / variables for one row / respondent. This is done by specifying the row we want, then a comma and leaving the index for the row number open. We additionally show something else here: it is not necessary to specify just a single value: a combination or range of values is fine as well. So: here we want the values stored in all the columns of the data.frame for the third and fourth row. We achieve this by indexing the data.frame 'r' using [3:4, ].</p>
<p><code><br />
&gt; y<br />
[1] 4 5<br />
&gt; c<br />
     [,1] [,2] [,3] [,4] [,5]<br />
[1,]    1    2    3    4    5<br />
[2,]    6    7    8    9   10<br />
&gt; r<br />
  p     q<br />
1 1   one<br />
2 2   two<br />
3 3 three<br />
4 4  four<br />
5 5  five<br />
&gt;<br />
&gt; y[2]<br />
[1] 5<br />
&gt; c[2,3]<br />
[1] 8<br />
&gt; r[3,1]<br />
[1] 3<br />
&gt; r$q<br />
[1] one   two   three four  five<br />
Levels: five four one three two<br />
&gt; r[3:4,]<br />
  p     q<br />
3 3 three<br />
4 4  four<br />
</code></p>
<h2>Managing variables</h2>
<p>So, we have created a number of variables. Although present day computers can easily remember such small amounts of data we've put in them, it forms a good habit to clean up variables when they are no longer needed. This is to preserve memory when working with large (real-life) data-sets and because you don't want to mistakenly mix variables up.</p>
<p>Variables in R-Project are stored in what is called the working space. There is much more to it than will be described here, since not only variables are stored in the working space. We can see what variables we created by using the ls() function. We receive a list of the ten variables we created in this paragraph. If you've been working on some other project in R, such as previous paragraphs of the manual, other objects might be named as well.</p>
<pre lang="rsplus" line="1">
ls()
</pre>
<p><code><br />
&gt; ls()<br />
 [1] "a" "b" "c" "d" "p" "q" "r" "x" "y" "z"<br />
</code></p>
<p>Now we want to clean up a bit. This can be done by using the rm() (rm = remove) function. Between the brackets the variables that need to be deleted are specified. We first delete all the variables, except the ones that were associated with creating the data.frame because we will need them below. When a new ls() is called for, we see that the variables are gone.</p>
<pre lang="rsplus" line="1">
rm(a,b,c,d,x,y,z)
ls()
rm(p,q)
</pre>
<p><code><br />
&gt; rm(a,b,c,d,x,y,z)<br />
&gt; ls()<br />
[1] "p" "q" "r"<br />
&gt; rm(p,q)<br />
</code></p>
<p>Remember that the variables 'p' and 'q' were stored inside the data.frame we called 'r'. Therefor, we don't need them anymore. They are thus deleted as well.</p>
<h2>Attaching data.frames</h2>
<p>When working with survey data, as the quantitative sociologist often does, data.frames are often the type of data-storage of choice. As we have already seen, variables stored in data.frame can be addressed individually or group-wise.  But in daily practice, this can become very tedious to be typing all the indexes when working with specific (subsets of) variables. Fortunately it is possible to bring the variables stored in a data.frame to the foreground by attaching them to the active work-space.</p>
<pre lang="rsplus" line="1">
 ls()
p
r
attach(r)
ls()
p
r
detach(r)
</pre>
<p>In the syntax above, a list of the available data-objects is requested. We see in the output below that only 'r' is available, which we remember to be a data.frame containing the variables 'p' and 'q'. When 'p' is called for directly, an error message is returned: object "p" is not to be found.</p>
<p>In such cases, we can tell R-Project where too look by indexing (as done above), or by attaching the data.frame. This is done by the attach() function. When we request a list of available object again, we still see only the data.frame 'r' coming up, but when object 'p' is requested, we now see it returned. The data.frame can still be called for normally. Finally we can bring the data.frame back to the 'background' by using the detach() function.</p>
<p>One word of notice: when working with an attached data.frame, it is very important to keep track of changes made to the variables. The 'p'-variable we could call for when the data.frame was attached, is <strong>not</strong> the same as the 'p'-variable stored inside the data.frame. So, changes made to the 'p'-variable when the data.frame is attached are lost when the data.frame is detached. This of course does not hold when the changes are made directly to the variables inside the data.frame.</p>
<p><code><br />
&gt; ls()<br />
[1] "r"<br />
&gt; p<br />
Error: object "p" not found<br />
&gt; r<br />
  p     q<br />
1 1   one<br />
2 2   two<br />
3 3 three<br />
4 4  four<br />
5 5  five<br />
&gt; attach(r)<br />
&gt; ls()<br />
[1] "r"<br />
&gt; p<br />
[1] 1 2 3 4 5<br />
&gt; r<br />
  p     q<br />
1 1   one<br />
2 2   two<br />
3 3 three<br />
4 4  four<br />
5 5  five<br />
&gt; detach(r)<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-07-data-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 06: Most Basic of All</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-06-most-basic-of-all/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-06-most-basic-of-all/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 10:00:03 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=415</guid>
		<description><![CDATA[In this edition of the R-Sessions the most basic of the basics are introduced. Attention will be paid to basic calculations, still the basis of every refined statistical analysis. Furthermore, storing data and using stored data in functions is introduced.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p>In this section of my R manual, the most basic of the basics are introduced. Attention will be paid to basic calculations, still the basis of every refined statistical analysis. Furthermore, storing data and using stored data in functions is introduced.</p>
<h2>Calculations in R</h2>
<p>R can be used as a fully functional calculator. When R is started, some licensing information is shown, as well as a prompt ( &gt; ). When commands are typed and ENTER is pressed, R starts working and returns the outcome of the command. Probably the most basic command that can be entered is a basic number. Since it is not stated what to do with this number, R simply returns it. Some special numbers have names. When these names are called, the corresponding number is returned. Finally, next to numbers, text can be handled by R as well.</p>
<pre lang="rsplus" line="1">
3
3 * 2
3 ^ 2
pi
apple
"apple"
</pre>
<p>In the box above six commands were entered to the R prompt. These commands can be entered one by one, or pasted to the R-console all at once. After these commands are entered one by one, the screen looks like this:<br />
<span id="more-415"></span><br />
<code>&gt; 3<br />
[1] 3<br />
&gt; 3 * 2<br />
[1] 6<br />
&gt; 3 ^ 2<br />
[1] 9<br />
&gt;<br />
&gt; pi<br />
[1] 3.141593<br />
&gt; apple<br />
Error: object "apple" not found<br />
&gt; "apple"<br />
[1] "apple"<br />
</code></p>
<p>On the first row, we see after the prompt ( &gt; ) our first &#8216;command&#8217;. The row below is used by R to give us the result. The indication [1] means, that it is the first outcome that is first printed on that row. This may seem quite obvious (which it is), but can become very useful when working with larger sets of data.<br />
The next few rows show the results of a few basic calculations. Nothing unexpected here. When PI is called for, the expected number appears. This is because R has a set of these numbers available, called constants. When an unknown name is called, an error message is given. R does not know a number, or anything else for that matter, called apple. When the word apple is bracketed (&#8221; &#8220;), it is seen as a character string and returned just like the numbers are.</p>
<h2>Combining values</h2>
<p>In statistics, we tend to use more than just single numbers. R is able to perform calculation on sets of data in exactly the same way as is done with single numbers. This is shown below. Several numbers can be combined into one &#8216;unit&#8217; by using the c() command. C stands for concatenate. So, as the two first commands below try to achieve, we can combine both numbers as well as character strings.  As said, we can use these ranges of data in our calculation. When we do so, shorter ranges of data are iterated to match the length of the longer / longest range of data.</p>
<pre lang="rsplus" line="1">
c(3,4,3,2)
c("apple", "pear", "banana")

3 * c(3,4,3,2)
c(1,2) * c(3,4,3,2)
c(1,2,1,2) * c(3,4,3,2)
</pre>
<p>In the output below, we see that the first two commands lead to the return of the created units of combined data. As above, we see the [1]-indicator, while four or three items are returned. This is because R indicates the number / index of the first item on a row only. When we multiply the range of four number by a single number (3), all the individual numbers are multiplied by that number. In de final two command-lines, two numbers are multiplied by four number. This results in a 2-fold iteration of the two numbers. So, the result of the two last commands are the same.</p>
<p><code>&gt; c(3,4,3,2)<br />
[1] 3 4 3 2<br />
&gt; c("apple", "pear", "banana")<br />
[1] "apple"  "pear"   "banana"<br />
&gt;<br />
&gt; 3 * c(3,4,3,2)<br />
[1]  9 12  9  6<br />
&gt; c(1,2) * c(3,4,3,2)<br />
[1] 3 8 3 4<br />
&gt; c(1,2,1,2) * c(3,4,3,2)<br />
[1] 3 8 3 4<br />
</code></p>
<h2>Storing data</h2>
<p>The results of our calculations can be stored in object, often called variables. Using his capability saves us a lot of time typing in our data. It also allows for more complex calculations, as we will see later. We can assign single or multiple values to an object by the assign operator: &lt;- . This operator can be used in opposite direction  (-&gt;) as well. When only an object, which has a value assigned to it, is entered to the console, its&#8217; contents are shown.</p>
<pre lang="rsplus" line="1">
x <- 3
x
x -> z
z
2*x
y &#038;<- c(3,4,3,2)
y
x*y

z <- c("apple", "pear", "banana")
z
</pre>
<p>The syntax above leads to the output shown below. In the first row, the value '3' is assigned to object x, which was unknown to R before. So, in many cases, objects do not have to be defined before data is assigned. When the object 'x' is entered to the console, the value that was assigned to it is returned. Next, the value of object 'x' is assigned to object 'z'. Note that the assign-operator is in opposite direction here, but it functions in exactly the same way (expect the direction of assignment, of course).<br />
Next, it is shown that not only single values can be assigned to objects, but ranges of values as well. When we have more than one object with values assigned to it, these object can be used to perform calculations, as is shown by multiplying x by y.<br />
The final example shows us two things. First of all: not only numbers can be assigned to objects, but character strings as well. Secondly, we assign these character strings to an object that was already containing other values. We see now, that the old values are overwritten by the new values.</p>
<p><code>&gt; x &lt;- 3<br />
&gt; x<br />
[1] 3<br />
&gt; x -&gt; z<br />
&gt; z<br />
[1] 3<br />
&gt; 2*x<br />
[1] 6<br />
&gt; y &lt;- c(3,4,3,2)<br />
&gt; y<br />
[1] 3 4 3 2<br />
&gt; x*y<br />
[1]  9 12  9  6<br />
&gt;<br />
&gt; z &lt;- c("apple", "pear", "banana")<br />
&gt; z<br />
[1] "apple"  "pear"   "banana"<br />
</code></p>
<h2>Functions and stored data</h2>
<p>Many of the object we create in R can be entered into the multitude of functions that are available. A very straightforward function in mean(). As we can see in the syntax and the output below, this function behaves exactly the same when a range of values or an object with that range of values is entered. We also learn from these examples that the results of functions can be stored in objects as well.</p>
<pre lang="rsplus" line="1">
mean(c(3,4,3,2))
y <- c(3,4,3,2)
mean(y)
m <- mean(y)
m
</pre>
<p><code><br />
&gt; mean(c(3,4,3,2))<br />
[1] 3<br />
&gt; mean(y)<br />
[1] 3<br />
&gt; m &lt;- mean(y)<br />
&gt; m<br />
[1] 3</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-06-most-basic-of-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-Sessions 05: Getting Help</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-05-getting-help/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-05-getting-help/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 10:00:14 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=413</guid>
		<description><![CDATA[Concordant with the open source community, R-Project is accompanied by many additional help functions. Most of them are freely available.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p><!--adsense--><br />
Concordant with the open source community, R-Project is accompanied by many additional help functions. Most of them are freely available.</p>
<h2>The help() &#8211; function</h2>
<p>R-Project has a help function build in. This functionality is focused on informing the user on the parameters function have. Almost for all functions some examples are given as well.</p>
<p>A general help page is available, which contains several introductory documents as &#8216;An Introduction to R&#8217;, &#8216;Frequently Asked Questions&#8217;, and &#8216;The R Language Definition&#8217;. More advanced documents are made available as well, such as &#8216;Writing R Extensions&#8217; and &#8216;R Internals&#8217;. This general help page is called for by entering:</p>
<blockquote><p> help.start()</p></blockquote>
<p>To obtain help on a specific function, you use help() with the name of the function between the brackets. For instance, if you want help on the plot() function, use the following syntax:</p>
<blockquote><p> help(plot)</p></blockquote>
<p>This results in a page that gives a short definition of the function, shows the parameters of the function, links to related functions, and finally gives some examples.</p>
<h2>Freely available documents</h2>
<p>More elaborate documents can be found on the website of R-Project (http://www.r-project.org) in the documents section. This can be found by clicking on &#8216;manuals&#8217; from the home-page, just below the &#8216;documents&#8217; header. First, a couple of documents written by the core development team of R-Project are offered, but don&#8217;t forget to click on the &#8216;Contributed Documentation&#8217; link, which leads to many more documents, often of a very high quality.</p>
<h2>Books on R-Project</h2>
<p>Many books have been written on R-Project, ranging from very basic-level introductions to the ones that address the fundamental parts of the software. In this manual I review some of these books, which I can advise to every starting or more advanced user of R-Project:</p>
<ul>
<li>Mixed-Effect Models in S and S-Plus, by JosÃ© Pinheiro &amp; Douglas Bates</li>
<li>An R and S-PLUS Companion to Applied Regression, by John Fox</li>
<li>Introductory Statistics with R, by Peter Dalgaard</li>
<li>Data Analysis Using Regression and Multilevel / Hierarchical Models, by Andrew Gelman and Jennifer Hill</li>
</ul>
<h2>R-help mailinglist</h2>
<p>When all help fails, there is always the R-Help mailing-list. This is a service where all members receive the e-mails that are send to a specific address. The quality and speed of the given answers and solutions is often very high. Questions are asked and answered many times a day, so be prepared to receive a high volume of e-mail when signing up for this service.</p>
<p>More information on the R-help mailing-list, as well as the ability to sign-up, can be found on: https://stat.ethz.ch/mailman/listinfo/r-help</p>
<p><span id="more-413"></span></p>
<p><i><br />
&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-05-getting-help">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/introduction/getting-help/">Find the original article embedded in the manual.</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-05-getting-help/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>R-Sessions 04: Getting Packages</title>
		<link>http://www.rensenieuwenhuis.nl/r-sessions-04/</link>
		<comments>http://www.rensenieuwenhuis.nl/r-sessions-04/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 10:00:44 +0000</pubDate>
		<dc:creator><![CDATA[Rense Nieuwenhuis]]></dc:creator>
				<category><![CDATA[R-Project]]></category>
		<category><![CDATA[R-Sessions]]></category>
		<category><![CDATA[Academic Software]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.rensenieuwenhuis.nl/?p=409</guid>
		<description><![CDATA[A freshly installed version of R-Project can do some pretty nice things already, but much more functionality can be obtained by installing packages that contain new functions. These packages are available by the internet and can be installed from within R-Project.  Let's say we want to use the lme4-package, which can be used to estimate linear and generalized multilevel models. The lme4-package does not come pre-installed with R-Project, so we have to download and install is manually. The way this is done is shown based on an R-installation on windows XP.]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/"><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2008/07/r-sessions.jpg?w=470" " title="R-Sessions" data-recalc-dims="1" /></a></p>
<p><!--adsense--><br />
A freshly installed version of R-Project can do some pretty nice things already, but much more functionality can be obtained by installing packages that contain new functions. These packages are available by the internet and can be installed from within R-Project.  Let&#8217;s say we want to use the lme4-package, which can be used to estimate linear and generalized multilevel models. The lme4-package does not come pre-installed with R-Project, so we have to download and install is manually. The way this is done is shown based on an R-installation on windows XP.</p>
<h2>Is the package installed?</h2>
<p>Before we start to install a package, it is a good custom to check whether or not it is already installed. We start R-project and see the basic screen of the software.  <img src="http://i0.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/screenshot-package-01.gif?w=470" alt="Screenshot package 01" data-recalc-dims="1" />  Choose &#8216;Packages&#8217; from the menu&#8217;s at the top of the screen. Six options are offered:</p>
<ul>
<li><strong>Load Package</strong>: This is used to load packages that are already installed</li>
<li><strong>Set CRAN Mirror</strong>: Choose from which server the packages should be downloaded</li>
<li><strong>Select repositories</strong>: Choose CRAN and CRAN (extras)</li>
<li><strong>Install package(s)</strong>: Download and install new packages</li>
<li><strong>Update packages</strong>: Download new versions of already installed packages when available</li>
<li><strong>Install package(s) from local zip files</strong>: Used for computers not connected to the internet</li>
</ul>
<p><span id="more-409"></span><br />
By selecting &#8216;Load Package&#8217; we can check whether the &#8216;lme4&#8242;-package we want is already installed. It appears not to. Click on &#8216;Cancel&#8217; to return to the main screen of P-Project. Note that some R-syntax is printed in red in the R-Console window. This is the syntax that can be used to manually call for the window to selects packages to load.</p>
<p><img src="http://i1.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/screenshot-package-02.gif?w=175" title="Screenshot package 02" alt="Screenshot package 02" align="left" data-recalc-dims="1" /></p>
<h2>Installing the package</h2>
<p>Since the lme-package we want is not already installed, we are now going to do this. Select &#8216;Packages&#8217; from the menu at the top of the screen and then &#8216;Install Package(s)&#8230;&#8217;.   A window pops up asking us to choose a CRAN-mirror. This is done only once during a session of R-Project. We have to choose where the package will be downloaded from and it is advisable to select one near the location you&#8217;re at. I chose &#8216;Netherlands (Utrecht)&#8217;.  <img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/screenshot-package-03.gif?w=175" title="Screenshot package 03" alt="Screenshot package 03" align="middle" data-recalc-dims="1" /></p>
<p>After a short while that is needed to download a list of the available packages (internet connection is needed!), a new screen called &#8216;Packages&#8217; pops forward and allows the user to select a package to install. The length of the list gives an impression of the many packages available and the many ways R-Project can be extended to fit your specific needs. I choose lme4 here and click on &#8216;OK&#8217;.   The lme4-package is downloaded and installed automatically and can be activated now. But first: note that in some cases other packages are loaded as well. In this case the Matrix-package is installed, because the requested lme4-package depends on it. This is done to ensure a fully working version of R-Project at all times.<br />
<img src="http://i2.wp.com/www.rensenieuwenhuis.nl/wp-content/uploads/2007/07/screenshot-package-04.gif?w=175" title="Screenshot package 04" alt="Screenshot package 04" align="middle" data-recalc-dims="1" /></p>
<h2>Loading the package</h2>
<p>Now, the new package can be loaded and used. As described above, this can be done by clicking on &#8216;Packages&#8217; on the menu-bar at the top of the screen and then on &#8216;Load Packages &#8230;&#8217;. It can be done manually as well using the following syntax:</p>
<blockquote><p> library(lme4)</p></blockquote>
<p>This loads the package and by default loads the packages it depends on as well if these were not loaded already. In this case, the lattice-package (for trellis graphics) and the Matrix-package are loaded automatically.</p>
<p><i><br />
&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;</p>
<ul>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-forum/topic/r-sessions-04-getting-packages/">Discuss this article and pose additional questions in the R-Sessions Forum</a></b></li>
<li><b><a href="http://www.rensenieuwenhuis.nl/r-project/manual/introduction/getting-packages/">Find the original article embedded in the manual.</a></b></li>
</ul>
<p>&#8211; &#8211; &#8212; &#8212; &#8212;&#8211; &#8212;&#8212;&#8211;<br />
<a href="http://www.rensenieuwenhuis.nl/archive/category/r-project/r-sessions/">R-Sessions</a> is a collection of manual chapters for R-Project, which are maintained on <a href="www.rensenieuwenhuis.nl">Curving Normality</a>. All posts are linked to the chapters from the R-Project manual on this site. The manual is free to use, for it is paid by the advertisements, but please refer to it in your work inspired by it. Feedback and topic requests are highly appreciated.<br />
&#8212;&#8212;&#8211; &#8212;&#8211; &#8212; &#8212; &#8211; &#8211;<br />
</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rensenieuwenhuis.nl/r-sessions-04/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
