<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Psychwire</title>
	<atom:link href="http://psychwire.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://psychwire.wordpress.com</link>
	<description>Hayward&#039;s blog on psychology, visual cognition, and stats</description>
	<lastBuildDate>Tue, 14 Feb 2012 16:54:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='psychwire.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e2048594ed412ca08d3eb088c9a3b626?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Psychwire</title>
		<link>http://psychwire.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://psychwire.wordpress.com/osd.xml" title="Psychwire" />
	<atom:link rel='hub' href='http://psychwire.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Migrating from SPSS/Excel to R, Part 3: Preparing your Data</title>
		<link>http://psychwire.wordpress.com/2011/10/29/migrating-from-spssexcel-to-r-part-3-preparing-your-data/</link>
		<comments>http://psychwire.wordpress.com/2011/10/29/migrating-from-spssexcel-to-r-part-3-preparing-your-data/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 10:00:18 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[reshape]]></category>
		<category><![CDATA[spss]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=422</guid>
		<description><![CDATA[In this post, I describe how to prepare your data for migrating between SPSS/Excel and R. This is the third &#8230;<p><a href="http://psychwire.wordpress.com/2011/10/29/migrating-from-spssexcel-to-r-part-3-preparing-your-data/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=422&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post, I describe how to prepare your data for migrating between SPSS/Excel and R. This is the third post in a series, the first two of which can be found <a href="http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/">here</a> and <a href="http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/">here</a>. Don&#8217;t forget, this is primarily aimed at those working on datasets for psychology experiments, as that&#8217;s what I do.</p>
<h1>Datasets in SPSS/Excel</h1>
<p>One of the golden rules of working with datasets in SPSS is that you need to have <strong><em>one row for each participant</em></strong>. I know there are some exceptions to this, but it&#8217;s an important general rule for SPSS.</p>
<p>The main consequence of this is that, when you&#8217;re dealing with any form of within-subjects data, your dataset quickly becomes very wide indeed. Let&#8217;s look at an example below. Here, we have 10 participants, involved in two experimental sessions. For each session, we&#8217;ve measured the Reaction Time (RT).</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/spss_base.png"><img class="alignnone size-thumbnail wp-image-430" title="spss_base" src="http://psychwire.files.wordpress.com/2011/07/spss_base.png?w=150&#038;h=112" alt="" width="150" height="112" /></a></p>
<p>That&#8217;s not too messy (note that I just pasted in 1200 for the values as this is just an illustration). But let&#8217;s make things worse. Let&#8217;s have 10 experimental sessions, each with three different blocks of trials, each representing a different within-subjects condition. What does it look like now?</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/spss_wider.png"><img class="alignnone size-thumbnail wp-image-431" title="spss_wider" src="http://psychwire.files.wordpress.com/2011/07/spss_wider.png?w=150&#038;h=95" alt="" width="150" height="95" /></a></p>
<p>Well, we can&#8217;t fit it all into a single screenshot, as the dataset has a large number of columns. This is an illustration of what gets referred to as a <strong><em>wide </em></strong>data format &#8211; you have a large number of columns mapping on to various factors, variables, etc.</p>
<p>R does things differently, for most of the statistical tests that I&#8217;ll be discussing: it uses the <strong><em>long </em></strong>data format instead.</p>
<h1>Long Datasets in R</h1>
<p>When you think about it, wide datasets can be a real pain. I&#8217;ve seen people spend hours running pivot tables and then having to drag columns around to get their datasets in a format that SPSS will be happy with.</p>
<p>With R, things are significantly easier: for many tests, such as t-tests and ANOVAs of various forms, you only need to use a single layout: the long data format. You can probably guess what this is already, but let&#8217;s do a direct comparison using the first example dataset described above.</p>
<p>Again, let&#8217;s say we have Reaction Times (RTs) for 10 participants involved in two sessions of experimental trials. In wide format, these data look like this:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/r_wide.png"><img class="alignnone size-thumbnail wp-image-433" title="r_wide" src="http://psychwire.files.wordpress.com/2011/07/r_wide.png?w=143&#038;h=150" alt="" width="143" height="150" /></a></p>
<p>In the long format, these data look like this:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/r_long.png"><img class="alignnone size-thumbnail wp-image-432" title="r_long" src="http://psychwire.files.wordpress.com/2011/07/r_long.png?w=73&#038;h=150" alt="" width="73" height="150" /></a></p>
<p>Here you can see the difference: in the long format, the one row per participant rule does not apply. Instead, you have one row for each combination of factors under examination.</p>
<h1>What if your Datasets are all in the Wide Format?</h1>
<p>There are a number of options that you can use to convert between the two different formats. I&#8217;ve covered perhaps one of the easiest methods, in the form of the reshape package, in a previous post. You&#8217;ll need to install the <strong>reshape2</strong> package to do this, using the <a href="http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/">package installation guide I presented previously</a>.</p>
<p>Just to give an example, let&#8217;s work through the dataset I&#8217;ve been describing above.</p>
<p>First, let&#8217;s create some data:</p>
<p><pre class="brush: r;">

session1 &lt;- rnorm(mean=1500, sd=250, 10)

session2 &lt;- rnorm(mean=1000, sd=250, 10)

ppt &lt;- seq(1:10)

wide&lt;- data.frame(ppt, session1, session2)

</pre></p>
<p>That gives us a dataframe called <strong>wide</strong>. How do we reshape the dataset to the long format that we want? Simple, by using the following:</p>
<p><pre class="brush: r;">

long&lt;- melt(wide, id=c(&quot;ppt&quot;))

</pre></p>
<p>This then gives us a dataframe called <strong>long</strong>, arranged in the format we want.</p>
<p>In many cases, if you want to avoid having to do this, it&#8217;s best to make sure your datasets are in the long format beforehand &#8211; it&#8217;s a simple case of planning ahead and knowing that you can do things differently.</p>
<h1>Summary and Next Steps</h1>
<p>This post illustrated how to get your data organised for use in R for those who are used to using SPSS/Excel. There are many useful ways to re-organise your data, and I&#8217;ve covered one of them here (the reshape package). The next steps include aggregating your data and then running statistical tests.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/422/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/422/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/422/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=422&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/10/29/migrating-from-spssexcel-to-r-part-3-preparing-your-data/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/spss_base.png?w=150" medium="image">
			<media:title type="html">spss_base</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/spss_wider.png?w=150" medium="image">
			<media:title type="html">spss_wider</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/r_wide.png?w=143" medium="image">
			<media:title type="html">r_wide</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/r_long.png?w=73" medium="image">
			<media:title type="html">r_long</media:title>
		</media:content>
	</item>
		<item>
		<title>Posters: Ready!</title>
		<link>http://psychwire.wordpress.com/2011/08/30/posters-ready/</link>
		<comments>http://psychwire.wordpress.com/2011/08/30/posters-ready/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 21:58:58 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=500</guid>
		<description><![CDATA[Here&#8217;s a short video on how best to use a poster tube prior to a conference.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=500&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a short video on how best to use a poster tube prior to a conference.</p>
<span style="text-align:center; display: block;"><a href="http://psychwire.wordpress.com/2011/08/30/posters-ready/"><img src="http://img.youtube.com/vi/QPih6N_5HKY/2.jpg" alt="" /></a></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/500/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=500&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/08/30/posters-ready/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>
	</item>
		<item>
		<title>Using visual interruptions to explore the extent and time course of fixation planning in visual search</title>
		<link>http://psychwire.wordpress.com/2011/08/23/ecem_godwin_benson_drieghe_interruptions_2011/</link>
		<comments>http://psychwire.wordpress.com/2011/08/23/ecem_godwin_benson_drieghe_interruptions_2011/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 06:00:48 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[eye movements]]></category>
		<category><![CDATA[psychology]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[visual cognition]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=483</guid>
		<description><![CDATA[Here is a permanent copy of my poster for the European Conference in Eye Movements Poster for the 2011 ECEM Meeting. &#8230;<p><a href="http://psychwire.wordpress.com/2011/08/23/ecem_godwin_benson_drieghe_interruptions_2011/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=483&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a permanent copy of my poster for the European Conference in Eye Movements Poster for the 2011 ECEM Meeting. The full reference is:</p>
<p>Godwin, H., Benson, V., &amp; Drieghe, D. (2011). <em>Using visual interruptions to explore the extent and time course of fixation planning in visual search.</em> Poster presented at the European Conference in Eye Movements, Marseille, France.</p>
<p>The poster can be downloaded via the following link:</p>
<p>Click here :<a href="http://psychwire.files.wordpress.com/2011/08/ecem_interruption_poster_final.pdf">ecem_interruption_poster_final</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/483/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=483&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/08/23/ecem_godwin_benson_drieghe_interruptions_2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>
	</item>
		<item>
		<title>Summer</title>
		<link>http://psychwire.wordpress.com/2011/08/15/summer/</link>
		<comments>http://psychwire.wordpress.com/2011/08/15/summer/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 20:53:10 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=497</guid>
		<description><![CDATA[Wow, what a summer it&#8217;s been so far, and it&#8217;s not even over yet. I&#8217;ve not had time to catch &#8230;<p><a href="http://psychwire.wordpress.com/2011/08/15/summer/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=497&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow, what a summer it&#8217;s been so far, and it&#8217;s not even over yet. I&#8217;ve not had time to catch up on the posts I&#8217;d started a while back- and it looks like I&#8217;ll be away for a while longer.</p>
<p>Normally, summers involve a slight easing up of the workload, thanks to there being no students around, allowing people to catch up with things&#8230;but not this time! It&#8217;s been fun though, it&#8217;ll just be a little while before I&#8217;m back.</p>
<p>&nbsp;</p>
<p>See you&#8230;out there&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/497/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=497&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/08/15/summer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>
	</item>
		<item>
		<title>Watching other People Watching other People – Summer Edition</title>
		<link>http://psychwire.wordpress.com/2011/07/18/watching-other-people-watching-other-people-%e2%80%93-summer-edition/</link>
		<comments>http://psychwire.wordpress.com/2011/07/18/watching-other-people-watching-other-people-%e2%80%93-summer-edition/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 10:00:37 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=474</guid>
		<description><![CDATA[The venerable Sean Upton recently took this shot of someone taking a photo of the rain, enjoying the summer. It&#8217;s &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/18/watching-other-people-watching-other-people-%e2%80%93-summer-edition/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=474&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The venerable <a href="http://twitter.com/#!/_dylarama_">Sean Upton</a> recently took this shot of someone taking a photo of the rain, enjoying the summer. It&#8217;s part of the <a href="http://psychwire.wordpress.com/2011/05/11/watching-other-people-watching-other-peopleevents/">growing</a> <a href="http://psychwire.wordpress.com/2011/07/17/watching-other-people-watching-other-people-international-edition/">series</a> of posts here looking at people watching other people and events. Thanks, Sean!</p>
<p>Click on the image to see an enlarged version.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/img_7254.jpg"><img class="alignnone size-thumbnail wp-image-476" title="IMG_7254" src="http://psychwire.files.wordpress.com/2011/07/img_7254.jpg?w=111&#038;h=150" alt="" width="111" height="150" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/474/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=474&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/18/watching-other-people-watching-other-people-%e2%80%93-summer-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/img_7254.jpg?w=111" medium="image">
			<media:title type="html">IMG_7254</media:title>
		</media:content>
	</item>
		<item>
		<title>Migrating from SPSS/Excel to R, Part 2: Working with Packages</title>
		<link>http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/</link>
		<comments>http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 09:09:50 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[Rstudio]]></category>
		<category><![CDATA[spss]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=440</guid>
		<description><![CDATA[In this post, I cover an important aspect of using R that users of SPSS/Excel won&#8217;t be familiar with: working &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=440&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post, I cover an important aspect of using R that users of SPSS/Excel won&#8217;t be familiar with: working with packages. Packages and the package system form a major difference between R and SPSS/Excel, which is why I&#8217;m devoting this entire post to them. It&#8217;s the second post in a series aimed at people wanting to migrate from SPSS/Excel to using R full-time. The previous post on this topic is <a href="http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/">available here</a>. Again, this post is aimed primarily at psychology researchers, as that&#8217;s what I am, though it will hopefully be relevant to others as well.</p>
<h1>Packages in R</h1>
<p>With SPSS/Excel, you pretty much get everything you could ever want to use, and more, installed with the default installation. This leads to a simple question. How many of the many hundreds of buttons, boxes and options in these programs have you used in total?</p>
<p>R is different. The basic installation of R comes with a large number of packages and commands. However, with R, people have been able to share their own packages which can help out, extend, and implement other useful things to make R even more funky and powerful. This is beneficial for a number of reasons, but, for the new user, it might seem a bit strange. Why doesn&#8217;t R just come with all the packages installed right away? Well, the chances are you won&#8217;t need <em>all </em>of the packages in existence, so there&#8217;s little point in installing them all by default. Doing so also reduces the size of an R download, saves hard drive space, and so on.</p>
<p>People are adding new and useful packages all the time, so let&#8217;s install a couple of popular ones that I use all the time.</p>
<h1>Installing Packages in R</h1>
<p>To get to the list of packages you have installed, go to the packages tab using RStudio:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/packages.png"><img class="alignnone size-thumbnail wp-image-443" title="packages" src="http://psychwire.files.wordpress.com/2011/07/packages.png?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<p>Packages are often updated, so you can use the <strong>Check for Updates </strong>button to update your packages.</p>
<p>To install a new package, you can either run the following command via the script tab or console window:</p>
<p><pre class="brush: r;">
install.packages(&quot;PACKAGENAME&quot;)
</pre></p>
<p>Where <strong>PACKAGENAME </strong>is the name of the package. Alternatively, using RStudio, you can hit the <strong>Install Packages</strong> button in the <strong>Packages </strong>window. You&#8217;ll be greeted with something like the following:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/install_packages.png"><img class="alignnone size-thumbnail wp-image-444" title="install_packages" src="http://psychwire.files.wordpress.com/2011/07/install_packages.png?w=150&#038;h=111" alt="" width="150" height="111" /></a></p>
<p>In this window, just type the name of the package you want to install in the <strong>Packages </strong>text box. Here, I&#8217;ve gone for <strong>ggplot2 </strong>and <strong>plyr</strong>.</p>
<p>Once you hit the <strong>install </strong>button, the packages will be installed. It&#8217;s best to leave <strong>Install Dependencies </strong>checked because some packages need others to function. For example, ggplot2 uses plyr.</p>
<p><span class="Apple-style-span" style="font-weight:bold;line-height:12px;">Loading Packages in R</span></p>
<p>The packages you have installed won&#8217;t be loaded straight away. If R loaded all the packages you had installed, then you would often end up with packages loaded that you don&#8217;t need to use. To load your packages, you can do one of two things. First you can run the command:</p>
<p><pre class="brush: r;">

library(PACKAGENAME)

</pre></p>
<p>Where <strong>PACKAGENAME </strong>is the name of the package that you want to load.</p>
<p>An alternative method is to select the package using RStudio&#8217;s <strong>Package </strong>window. To load the package(s) that you want, all you need to do is click the checkbox next to the package name. See below.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/load_package.png"><img class="alignnone size-thumbnail wp-image-449" title="load_package" src="http://psychwire.files.wordpress.com/2011/07/load_package.png?w=150&#038;h=117" alt="" width="150" height="117" /></a></p>
<p>There we go, <strong>ggplot2 </strong>has now been loaded! It&#8217;s also loaded <strong>plyr </strong>as <strong>ggplot2 </strong>needs plyr to function, as well as <strong>reshape</strong>.</p>
<p><strong>Getting Help with Using a Package</strong></p>
<p>Packages come with helpful documentation to get you started with using them. Again, you have two options in terms of accessing the documentation. First, you can type the command:</p>
<p><pre class="brush: r;">

?PACKAGENAME

</pre></p>
<p>Where <strong>PACKAGENAME </strong>is the name of your package.</p>
<p>Alternatively, you can click the name of the package in RStudio&#8217;s <strong>Packages </strong>window, as below.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/package_help.png"><img class="alignnone size-thumbnail wp-image-451" title="package_help" src="http://psychwire.files.wordpress.com/2011/07/package_help.png?w=120&#038;h=150" alt="" width="120" height="150" /></a></p>
<p>Whichever method you use, you&#8217;ll be presented with the documentation in your packages window, which you can browse to work out what you need to do to use the package.</p>
<p><img class="alignnone size-thumbnail wp-image-450" title="package_docs" src="http://psychwire.files.wordpress.com/2011/07/package_docs.png?w=118&#038;h=150" alt="" width="118" height="150" /></p>
<h1>Which Packages should you Install?</h1>
<p>One of the daunting aspects of getting started with R is choosing <em>how </em>to use it, and <em>what packages</em> to install. I&#8217;ll cover some suggested packages in future guides, but for the eager, there&#8217;s a great list of popular packages that has been put up online by Matthew Dowle, and is available <a href="http://unknownr.r-forge.r-project.org/toppkgs.html">at this link</a>. The list is also part of his unknownR package, which is worth trying out if you are new. When learning R, I used that list to inspire me in terms of which packages I should learn.</p>
<p>You should also keep an eye on community sites such as <a href="http://www.r-bloggers.com/">R-Bloggers</a>, as you&#8217;ll often read about packages, as well as other tips and tricks, that you can use and learn from.</p>
<p>UPDATE: Thanks to <a href="http://www.r-statistics.com/">Tal Galili&#8217;s</a> comment, readers may also want to check out <a href="http://cran.r-project.org/web/views/">CRAN task views</a>, which has detailed info on a huge range of packages.</p>
<h1>Next Steps</h1>
<p>In the next guide, I&#8217;ll get into the interesting stuff: importing and manipulating data, and how doing so differs from SPSS/Excel.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/440/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/440/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/440/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=440&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/17/migrating-from-spssexcel-to-r-part-2-working-with-packages/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:thumbnail url="http://psychwire.files.wordpress.com/2011/07/install_packages.png?w=150" />
		<media:content url="http://psychwire.files.wordpress.com/2011/07/install_packages.png?w=150" medium="image">
			<media:title type="html">install_packages</media:title>
		</media:content>

		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/packages.png?w=150" medium="image">
			<media:title type="html">packages</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/load_package.png?w=150" medium="image">
			<media:title type="html">load_package</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/package_help.png?w=120" medium="image">
			<media:title type="html">package_help</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/package_docs.png?w=118" medium="image">
			<media:title type="html">package_docs</media:title>
		</media:content>
	</item>
		<item>
		<title>Watching other People Watching other People &#8211; International Edition</title>
		<link>http://psychwire.wordpress.com/2011/07/17/watching-other-people-watching-other-people-international-edition/</link>
		<comments>http://psychwire.wordpress.com/2011/07/17/watching-other-people-watching-other-people-international-edition/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 09:07:00 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=459</guid>
		<description><![CDATA[Young David Corck-Adelman has been travelling the world lately after finishing his PhD, and sent on a photo as part &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/17/watching-other-people-watching-other-people-international-edition/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=459&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Young <a href="http://www.southampton.ac.uk/psychology/postgraduate/research_students/dca106.page?">David Corck-Adelman</a> has been travelling the world lately after finishing his PhD, and sent on a photo as part of the <em><a href="http://psychwire.wordpress.com/2011/05/11/watching-other-people-watching-other-peopleevents/">Watching other People Watching other People </a></em>photograph series. This photo was taken in Hong Kong of all places. Thanks, Dave!</p>
<p>Click the image below to enlarge.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/hk.png"><img class="alignnone size-thumbnail wp-image-460" title="hk" src="http://psychwire.files.wordpress.com/2011/07/hk.png?w=150&#038;h=112" alt="" width="150" height="112" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/459/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/459/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/459/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=459&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/17/watching-other-people-watching-other-people-international-edition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/hk.png?w=150" medium="image">
			<media:title type="html">hk</media:title>
		</media:content>
	</item>
		<item>
		<title>Migrating from SPSS/Excel to R</title>
		<link>http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/</link>
		<comments>http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 21:44:21 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[psychology]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[Rstudio]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=312</guid>
		<description><![CDATA[In this post, I give an outline for those interested in migrating from using SPSS and Excel for data processing/analysis &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=312&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post, I give an outline for those interested in migrating from using SPSS and Excel for data processing/analysis across to using R for data processing/analysis. This will be the first post in a small series: it&#8217;s aimed at psychology researchers &#8211; as that&#8217;s what I am, but I&#8217;m sure much of this will apply to people from other fields/disciplines. For the purposes of this, I&#8217;ll assume that you do your data manipulation (e.g., pivot tables and organising datasets) using Excel, and your stats using SPSS. I also assume you use either SPSS or Excel, or perhaps an alternative package such as SigmaPlot, to make your graphs for publications.</p>
<p><span id="more-312"></span></p>
<p><span class="Apple-style-span" style="font-weight:bold;line-height:12px;">Before you Start</span></p>
<p>Before we get into any details, I need to point out something important. Whatever you do, DON&#8217;T sit down with R in front of you, clutching a dataset in your hand, and expect to be able to do everything you could in SPSS/Excel straight away. I&#8217;ve seen many people try this, expecting R to be identical to what they are used to from SPSS/Excel, and they, not surprisingly, give up very quickly. Just remember this: you&#8217;ve probably spent years working with SPSS and Excel, beginning as an undergrad, so this process will take time &#8211; but that doesn&#8217;t mean you should give up, like I&#8217;ve seen many people do. The investment of time is more than worth it!</p>
<h1>First Steps</h1>
<p>First off, <a href="http://www.r-project.org/">download R</a> to get started. Here is a <a href="http://www.stats.bris.ac.uk/R/bin/windows/base/R-2.13.1-win.exe">direct download link</a> if you don&#8217;t want to navigate the R websites.</p>
<p>After you download R and have it installed, I recommend picking up <a href="http://www.rstudio.org/">RStudio</a> and installing that. Load up RStudio. It will look something like this (click image to enlarge):</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_base.png"><img class="size-thumbnail wp-image-394 alignnone" title="rstudio_base" src="http://psychwire.files.wordpress.com/2011/07/rstudio_base.png?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<h1>Orienting Yourself</h1>
<p>Now, there are several points worth considering when you are faced with your new setup. First, you can now officially forget about the annoyances of having to switch between programs to do different things: gone are your days of using Excel to manipulate data, then importing it to SPSS, then graphing it, and then realising there&#8217;s something horribly wrong with it. I&#8217;ve had that happen plenty of times &#8211; spotting an error at the very end of the long chain of processes. The worst thing about when this happens is that you then need to go back to step #1 and start from scratch. It&#8217;s no fun at all.</p>
<p>R changes all of that. You have SPSS, Excel and Sigmaplot all rolled into one &#8211; with oodles of other features packed in besides (plus you have the option of adding more features and packages yourself). More importantly, as you will be writing scripts to do all your data processing and graphs, if you do detect an error, it&#8217;s a case of tweaking your script and then re-running it. Gone will be the days when you had to laboriously click through pivot tables, pasting into loads of new worksheets, losing your place and getting confused&#8230;and so on. You&#8217;ll find yourself wondering why you ever did things like that in the first place.</p>
<p>I&#8217;ll now go through what you have in front of you &#8211; taking each part step by step.</p>
<h1>The Scripting/Data Tabs and Console Window</h1>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_areas.png"><img class="alignnone size-thumbnail wp-image-398" title="rstudio_areas" src="http://psychwire.files.wordpress.com/2011/07/rstudio_areas.png?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<p>In the scripting tab(s) area (yellow), you have access to scripts that you write. Scripts consist of commands that you run and send to R to do things.</p>
<p>The Console (highlighted red) is a bit like the output window you get from SPSS. However, unlike the SPSS output window, it&#8217;s interactive, so you can type commands to it directly rather than just seeing buckets of text spewed out. This is useful if you want to test something out or just run something once. For example, type:</p>
<p>&gt;40+2</p>
<p>in the console and press Return. It nicely gives you the answer.</p>
<p>[1] 42</p>
<p>To see what the script tab can be used for, and for what scripts can be used for in general, type the same command in again into the script. All you need is to type 40+2. Then, click anywhere in the row where you have typed your command, and click the <strong>Run</strong> button (see image below). This sends the command from the line in your script directly to the console. You&#8217;ll see other buttons nearby that have other, related functions &#8211; hover over them for tooltips.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_commands.png"><img class="alignnone size-thumbnail wp-image-401" title="rstudio_commands" src="http://psychwire.files.wordpress.com/2011/07/rstudio_commands.png?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<p>If you find yourself clicking run, and noticing the console output just adding more &#8216;&gt;&#8217; signs to the output, it means you haven&#8217;t clicked the line containing your command. Try clicking the line containing 40+2 with your mouse and running the command again.</p>
<p>Next up, try adding some additional lines of basic maths to your script, highlight the lines with your mouse, and then hit run again. If you have multiple lines of commands in your script to run, then you need to highlight them with your mouse. When you run them, you&#8217;ll see that these lines have all been sent to the console, with the answers coming out at the appropriate times.</p>
<h1>The Workspace</h1>
<p>In Excel, you were used to having multiple worksheets with different datasets in them. These quickly become difficult to use when you have large numbers of worksheets to sift through. In SPSS, you need to have one main SPSS window open for each dataset. This could rapidly lead to having many SPSS windows open, causing annoyance and confusion about which one to work from.</p>
<p>R and RStudio takes a different approach entirely. In R, you have a <strong>workspace</strong> (users of Matlab will be familiar with this), and RStudio allows you to get an overview of your workspace in a glance. Gone are the days of many worksheets from Excel or many data windows in SPSS. The workspace in RStudio is highlighted below.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_highlight.jpg"><img class="alignnone size-thumbnail wp-image-402" title="rstudio_workspace_highlight" src="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_highlight.jpg?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<p>Let&#8217;s begin by demonstrating the purpose of the workspace. Type the following into a script and run it, or into the console itself:</p>
<p>answer &lt;- 42</p>
<p>You will then see <strong>answer </strong>appear in the workspace with a <strong>value </strong>of 42.</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_answer.jpg"><img class="alignnone size-thumbnail wp-image-411" title="rstudio_workspace_answer" src="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_answer.jpg?w=143&#038;h=150" alt="" width="143" height="150" /></a></p>
<p>But, this works not only with individual values &#8211; you can access, store and manipulate entire sets of data like this as well. Let&#8217;s create ourselves a little data set to begin with. Typically we work with <strong>dataframes</strong> in R, so we&#8217;ll call them that from now on. Just think of them a bit like a data window in SPSS, or a worksheet in Excel.</p>
<p>Next, run the following command:</p>
<p>testdf &lt;- data.frame(&#8220;values&#8221;=rnorm(mean=5,sd=1,100))</p>
<p>What this does is create a dataframe called <strong>testdf </strong>- don&#8217;t worry about the details too much just yet, as I&#8217;ll get to handling data in the next post in this series. What this dataframe contains is a list of 100 values randomly selected from a normal distribution with a mean of five and standard deviation of one. When you run the command, you&#8217;ll notice that testdf gets added to your workspace:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe.jpg"><img class="alignnone size-thumbnail wp-image-408" title="rstudio_workspace_dataframe" src="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe.jpg?w=143&#038;h=150" alt="" width="143" height="150" /></a></p>
<p>One of the useful features here is that it gives us information about the number of rows (&#8220;100 obs.&#8221;) and the number of columns (&#8220;1 variables&#8221;) in our dataframe. This is often helpful for diagnostics and making sure we know what we&#8217;ve done with our data when it&#8217;s been copied/merged/transformed/etc.</p>
<p>Finally, when you want to take a look at your dataframe, all you need to do is click the name of it in the workspace &#8211; a single-click is all you need. That will then open a new tab showing your data, like so:</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe_tab.jpg"><img class="alignnone size-thumbnail wp-image-409" title="rstudio_workspace_dataframe_tab" src="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe_tab.jpg?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<p>This now allows you to look at all of your data &#8211; though unlike SPSS and Excel, it does mean that you have open in tabs the data you need to look at, rather than everything. Personally I feel this makes everything seem cleaner and less cluttered, but that may just be me! I know that everyone has their own personal way of dealing with things like this.</p>
<h1>Plots</h1>
<p>Let&#8217;s end with making a very simple plot. For now, we&#8217;ll make a histogram of our dataframe. To do that, enter the following command:</p>
<p>hist(testdf$values)</p>
<p>You can see the plot shown in the <strong>Plots </strong>area in the bottom-right-hand corner of the display &#8211; shown in the image below. My randomly-selected values show a reasonably normal distribution!</p>
<p><a href="http://psychwire.files.wordpress.com/2011/07/rstudio_histogram.jpg"><img class="alignnone size-thumbnail wp-image-410" title="rstudio_histogram" src="http://psychwire.files.wordpress.com/2011/07/rstudio_histogram.jpg?w=150&#038;h=116" alt="" width="150" height="116" /></a></p>
<h1>Next Steps</h1>
<p>That&#8217;s it for now. Hopefully this will serve as a basic orientation for using R with RStudio. For the next posts in the series, I&#8217;ll finish a tour of R, and then there will be a discussion on how to organise your data for R &#8211; in some cases, it&#8217;s a slightly different approach to SPSS, so is worth discussing in detail.</p>
<p>UPDATE: As Ian Fellows kindly points out in the comments, there are other GUIs available for R besides RStudio &#8211; including the excellent <a href="http://www.deducer.org/pmwiki/pmwiki.php?n=Main.TheDataViewer">Deducer</a>. I also discussed some of the other GUIs available in a <a href="http://www.psychwire.co.uk/2011/04/rstudio-revolution-analytics-and-deducer-a-tale-of-three-guis/">previous post</a> from when I was just starting to learn R.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/312/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=312&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/10/migrating-from-spssexcel-to-r/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_base.png?w=150" medium="image">
			<media:title type="html">rstudio_base</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_areas.png?w=150" medium="image">
			<media:title type="html">rstudio_areas</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_commands.png?w=150" medium="image">
			<media:title type="html">rstudio_commands</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_highlight.jpg?w=150" medium="image">
			<media:title type="html">rstudio_workspace_highlight</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_answer.jpg?w=143" medium="image">
			<media:title type="html">rstudio_workspace_answer</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe.jpg?w=143" medium="image">
			<media:title type="html">rstudio_workspace_dataframe</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_workspace_dataframe_tab.jpg?w=150" medium="image">
			<media:title type="html">rstudio_workspace_dataframe_tab</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/rstudio_histogram.jpg?w=150" medium="image">
			<media:title type="html">rstudio_histogram</media:title>
		</media:content>
	</item>
		<item>
		<title>Psychology and Airport Security at the Royal Society</title>
		<link>http://psychwire.wordpress.com/2011/07/09/psychology-and-airport-security-at-the-royal-society/</link>
		<comments>http://psychwire.wordpress.com/2011/07/09/psychology-and-airport-security-at-the-royal-society/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 10:00:28 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[airport]]></category>
		<category><![CDATA[dual-target]]></category>
		<category><![CDATA[eye movement]]></category>
		<category><![CDATA[prevalence]]></category>
		<category><![CDATA[psychology]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=332</guid>
		<description><![CDATA[This week, a contingent of plucky individuals from my lab have been presenting at the Royal Society&#8217;s Summer Science Exhibition. &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/09/psychology-and-airport-security-at-the-royal-society/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=332&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://psychwire.files.wordpress.com/2011/07/imag0389.jpg"><img class="size-full wp-image-372 alignright" title="IMAG0389" src="http://psychwire.files.wordpress.com/2011/07/imag0389.jpg?w=529" alt=""   /></a></p>
<p>This week, a contingent of plucky individuals from my lab have been presenting at the Royal Society&#8217;s Summer Science Exhibition. Sadly I couldn&#8217;t make it as I was on the one holiday I take each year! Now that I&#8217;m back, I thought it would be worth discussing their exhibit, and encouraging anyone who hasn&#8217;t been yet to go!</p>
<p>The exhibit covers details of the work we&#8217;ve been doing for years on airport security screening (first publication was back in 2004). You can see an introduction into the research in the video below. Apparently they are working on upping the sound a bit.</p>
<span style="text-align:center; display: block;"><a href="http://psychwire.wordpress.com/2011/07/09/psychology-and-airport-security-at-the-royal-society/"><img src="http://img.youtube.com/vi/dfLMVgZTSDs/2.jpg" alt="" /></a></span>
<p>Our experiments are still alive and kicking, and we&#8217;ll be doing more work on it for (at least) the next 4-5 years &#8211; so watch this space! Aside from the practical benefits that this type of research has on offer, it&#8217;s turned out to be a very significant and useful source of inspiration for developing current models and theories of how humans search their environments for targets of various types. I wrote some more detailed stuff on<span class="Apple-style-span" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;"> </span><span class="Apple-style-span" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;"><a style="color:#990000;font:normal normal normal 12px/normal Verdana, Arial, Helvetica, sans-serif;font-style:inherit;font-weight:inherit;line-height:1.8;text-decoration:none;" href="http://www.psychwire.co.uk/research/airport-screening-and-the-dual-target-cost/">my website here</a></span><span class="Apple-style-span" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;"> </span><span class="Apple-style-span" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;">a while back.</span><span class="Apple-style-span" style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;"> </span></p>
<p>More information is available at the Royal Society&#8217;s website: <a href="http://royalsociety.org/summer-science/2011/airport-security/">click here</a>. By the way, the X-ray picture of a bag that they have used has nothing naughty in it. You can also play some online games developed for the exhibition <a href="http://royalsociety.org/images/sseflash/visualSearchExperiment.swf">here</a> and <a href="http://royalsociety.org/images/sseflash/EyeMovementGame.swf">here</a>.</p>
<p>Publications that are relevant to this can be found listed <a href="http://www.southampton.ac.uk/psychology/research/projects/visual_search_and_the_prevalence_effect.page?">here</a> and <a href="http://www.southampton.ac.uk/psychology/research/projects/visual_search_for_multiple_targets.page?">here</a>.</p>
<p>&#8212;</p>
<p>Finally, I&#8217;d like to dedicate this post to the computer used to do the eye tracking in that video above. It died on us a few days after the video was recorded. RIP.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=332&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/09/psychology-and-airport-security-at-the-royal-society/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://psychwire.files.wordpress.com/2011/07/imag0389.jpg?w=89" />
		<media:content url="http://psychwire.files.wordpress.com/2011/07/imag0389.jpg?w=89" medium="image">
			<media:title type="html">IMAG0389</media:title>
		</media:content>

		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>

		<media:content url="http://psychwire.files.wordpress.com/2011/07/imag0389.jpg" medium="image">
			<media:title type="html">IMAG0389</media:title>
		</media:content>
	</item>
		<item>
		<title>New Site Layout attempts to Take Advantage of Your Brain</title>
		<link>http://psychwire.wordpress.com/2011/07/08/new-site-layout-attempts-to-take-advantage-of-your-brain/</link>
		<comments>http://psychwire.wordpress.com/2011/07/08/new-site-layout-attempts-to-take-advantage-of-your-brain/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 22:35:54 +0000</pubDate>
		<dc:creator>Hayward Godwin</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://psychwire.wordpress.com/?p=368</guid>
		<description><![CDATA[I&#8217;ve changed the layout of the site a bit &#8211; including a new image of me looking like I know &#8230;<p><a href="http://psychwire.wordpress.com/2011/07/08/new-site-layout-attempts-to-take-advantage-of-your-brain/">Continue reading &#187;</a></p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=368&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve changed the layout of the site a bit &#8211; including a new image of me looking like I know what I&#8217;m doing on the left.</p>
<p>Looking at it more closely, I realise I&#8217;ve unintentionally done something quite sneaky. Given that humans naturally follow the gaze of other humans, when you visit the site and see me looking over towards the content of the page, you should follow my gaze and look over here as well. Some people suggested that people with autism fail to do this, but that&#8217;s not correct (<a href="http://www.mendeley.com/research/eye-movements-affirm-automatic-overt-gaze-arrow-cueing-typical-adults-adults-autism-spectrum-disorder/">sly link to some of my colleague&#8217;s research on just that topic</a>).</p>
<p>Imagine if I used that picture for nefarious purposes, you could be forced to look at something evil.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/psychwire.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/psychwire.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/psychwire.wordpress.com/368/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=psychwire.wordpress.com&amp;blog=22990573&amp;post=368&amp;subd=psychwire&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://psychwire.wordpress.com/2011/07/08/new-site-layout-attempts-to-take-advantage-of-your-brain/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/058d9b4b0da389096a4211c5b1a9296f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">psychwire</media:title>
		</media:content>
	</item>
	</channel>
</rss>
