<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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: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>Comments on: Design Flaws in R #3 — Zero Subscripts</title>
	<atom:link href="http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%E2%80%94-zero-subscripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/</link>
	<description></description>
	<lastBuildDate>Thu, 02 May 2013 20:17:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Chaos Theatre &#187; R: Statistical Bash</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-857</link>
		<dc:creator><![CDATA[Chaos Theatre &#187; R: Statistical Bash]]></dc:creator>
		<pubDate>Wed, 05 Dec 2012 07:32:35 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-857</guid>
		<description><![CDATA[[...] 1-indexing arrays. I know Matlab does this. That doesn&#8217;t make it right. And also they somehow did it worse than Matlab. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 1-indexing arrays. I know Matlab does this. That doesn&#8217;t make it right. And also they somehow did it worse than Matlab. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rickity Split Tankard</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-656</link>
		<dc:creator><![CDATA[Rickity Split Tankard]]></dc:creator>
		<pubDate>Fri, 06 Jan 2012 07:39:31 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-656</guid>
		<description><![CDATA[But the feature works so well with your other favourite feature! 

&gt; x &lt;- c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;)
&gt;
&gt; # 3 elements
&gt; i &lt;- 3; x[0:i]
[1] &quot;a&quot; &quot;b&quot; &quot;c&quot;
&gt; 
&gt; # 0 elements
&gt; i &lt;- 0; x[0:i]
character(0)
&gt; 
&gt; # with a 1 doesn&#039;t work so well:
&gt; i &lt;-0; x[1:i]
[1] &quot;a&quot;

&lt;strong&gt;RN:  I edited this to restore what I take to be what was intended.  Remember!  To enter a &quot;&lt;&quot; character, you need to use &quot;&lt;&quot;.&lt;/strong&gt;]]></description>
		<content:encoded><![CDATA[<p>But the feature works so well with your other favourite feature! </p>
<p>&gt; x &lt;- c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;)<br />
&gt;<br />
&gt; # 3 elements<br />
&gt; i &lt;- 3; x[0:i]<br />
[1] &quot;a&quot; &quot;b&quot; &quot;c&quot;<br />
&gt;<br />
&gt; # 0 elements<br />
&gt; i &lt;- 0; x[0:i]<br />
character(0)<br />
&gt;<br />
&gt; # with a 1 doesn&#039;t work so well:<br />
&gt; i &lt;-0; x[1:i]<br />
[1] &quot;a&quot;</p>
<p><strong>RN:  I edited this to restore what I take to be what was intended.  Remember!  To enter a &quot;&lt;&quot; character, you need to use &quot;&amp;lt;&quot;.</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R&#8217;s Dynamic Scoping &#171; LingPipe Blog</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-386</link>
		<dc:creator><![CDATA[R&#8217;s Dynamic Scoping &#171; LingPipe Blog]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 18:12:56 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-386</guid>
		<description><![CDATA[[...] Radford Neal: Two Surprising Things about R (following up his earlier series, design flaws in R) [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Radford Neal: Two Surprising Things about R (following up his earlier series, design flaws in R) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mariotomo</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-263</link>
		<dc:creator><![CDATA[mariotomo]]></dc:creator>
		<pubDate>Thu, 10 Dec 2009 14:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-263</guid>
		<description><![CDATA[yes, R is a funny language.  it does have its own logic, though!

R&gt; a&lt;-c(NA,3)
R&gt; a==3
[1]   NA TRUE
R&gt; a %in% 3
[1] FALSE  TRUE]]></description>
		<content:encoded><![CDATA[<p>yes, R is a funny language.  it does have its own logic, though!</p>
<p>R&gt; a&lt;-c(NA,3)<br />
R&gt; a==3<br />
[1]   NA TRUE<br />
R&gt; a %in% 3<br />
[1] FALSE  TRUE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radford Neal</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-192</link>
		<dc:creator><![CDATA[Radford Neal]]></dc:creator>
		<pubDate>Tue, 11 Nov 2008 19:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-192</guid>
		<description><![CDATA[I agree that it&#039;s not clear that an error should always be signalled when using NA in a subscript to &lt;i&gt;access&lt;/i&gt; elements.  I say above only that it should be an error when &lt;i&gt;replacing&lt;/i&gt; elements. 

However, I&#039;m not convinced that the example you give is good behaviour.  If I use a vector of TRUE/FALSE values as a subscript, I expect to get a vector whose length is equal to the number of TRUE values.  If some of these TRUE/FALSE values are actually NA, the length of vector to return is uncertain (if you think of NA as being unceretainly either TRUE or FALSE).  This is not at all the same as a vector of a well-defined length in which some elements are NA.  In particular, it&#039;s unlikely that the presence of the NA elements will correctly propagate through subsequent operations to produce a sensible result. So it may be best to signal an error when a logical vector containing an NA is used as a subscript.

The situation is different when the subscript is a vector of integers, some of which are NA.  Then the result should be a vector the same length as the subscript, and putting in NA where the subscript is NA correctly represents the uncertainty in the value of that subscript.

It&#039;s interesting that %in% handles NA the way you show, though I&#039;m not sure it&#039;s consistent with R&#039;s general treatment of NA!]]></description>
		<content:encoded><![CDATA[<p>I agree that it&#8217;s not clear that an error should always be signalled when using NA in a subscript to <i>access</i> elements.  I say above only that it should be an error when <i>replacing</i> elements. </p>
<p>However, I&#8217;m not convinced that the example you give is good behaviour.  If I use a vector of TRUE/FALSE values as a subscript, I expect to get a vector whose length is equal to the number of TRUE values.  If some of these TRUE/FALSE values are actually NA, the length of vector to return is uncertain (if you think of NA as being unceretainly either TRUE or FALSE).  This is not at all the same as a vector of a well-defined length in which some elements are NA.  In particular, it&#8217;s unlikely that the presence of the NA elements will correctly propagate through subsequent operations to produce a sensible result. So it may be best to signal an error when a logical vector containing an NA is used as a subscript.</p>
<p>The situation is different when the subscript is a vector of integers, some of which are NA.  Then the result should be a vector the same length as the subscript, and putting in NA where the subscript is NA correctly represents the uncertainty in the value of that subscript.</p>
<p>It&#8217;s interesting that %in% handles NA the way you show, though I&#8217;m not sure it&#8217;s consistent with R&#8217;s general treatment of NA!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kenn Konstabel</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-191</link>
		<dc:creator><![CDATA[Kenn Konstabel]]></dc:creator>
		<pubDate>Tue, 11 Nov 2008 10:13:24 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-191</guid>
		<description><![CDATA[I agree that many of the flaws referred to above are indeed flaws. But R&#039;s behavior in subsetting a vector with NA&#039;s makes perfect sense:

a&lt;-c(NA,3)
a[a==3]
# the first element might well be 3, were it not missing!!!!
# but if you want just 3&#039;s, no NA&#039;s:
# and it&#039;s not about subsetting, it&#039;s about comparing with `==`

a[a %in% 3]

#or
b &lt;- na.omit(a)
b[b==3]

# or even [very funny!!!]
a[sapply(a, identical, 3)]

I almost always use %in% instead of == in functions]]></description>
		<content:encoded><![CDATA[<p>I agree that many of the flaws referred to above are indeed flaws. But R&#8217;s behavior in subsetting a vector with NA&#8217;s makes perfect sense:</p>
<p>a&lt;-c(NA,3)<br />
a[a==3]<br />
# the first element might well be 3, were it not missing!!!!<br />
# but if you want just 3&#8242;s, no NA&#8217;s:<br />
# and it&#8217;s not about subsetting, it&#8217;s about comparing with `==`</p>
<p>a[a %in% 3]</p>
<p>#or<br />
b &lt;- na.omit(a)<br />
b[b==3]</p>
<p># or even [very funny!!!]<br />
a[sapply(a, identical, 3)]</p>
<p>I almost always use %in% instead of == in functions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radford Neal</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-171</link>
		<dc:creator><![CDATA[Radford Neal]]></dc:creator>
		<pubDate>Mon, 29 Sep 2008 13:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-171</guid>
		<description><![CDATA[Using = rather than &lt;- does avoid the formatting problems.

The effect of 4 versus -4 does seem a bit funny, though individually the definitions of what they do seem reasonably sensible (not necessarily the best way, since many buggy references will be considered valid, but not silly).

Many properties that one might hope for aren&#039;t going to be satisfied by R&#039;s indexing.  For instance, one might hope that saving the i&#039;th element in another variable, then setting it to something else, then setting it back to its saved value, would leave the vector unchanged.  But of course it won&#039;t if the index is beyond the previous extent of the vector.]]></description>
		<content:encoded><![CDATA[<p>Using = rather than &lt;- does avoid the formatting problems.</p>
<p>The effect of 4 versus -4 does seem a bit funny, though individually the definitions of what they do seem reasonably sensible (not necessarily the best way, since many buggy references will be considered valid, but not silly).</p>
<p>Many properties that one might hope for aren&#8217;t going to be satisfied by R&#8217;s indexing.  For instance, one might hope that saving the i&#8217;th element in another variable, then setting it to something else, then setting it back to its saved value, would leave the vector unchanged.  But of course it won&#8217;t if the index is beyond the previous extent of the vector.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandro Saitta</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-170</link>
		<dc:creator><![CDATA[Sandro Saitta]]></dc:creator>
		<pubDate>Mon, 29 Sep 2008 07:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-170</guid>
		<description><![CDATA[&gt; a = c(1,2,3)
&gt; a[4]
[1] NA
&gt; a[-4]
[1] 1 2 3]]></description>
		<content:encoded><![CDATA[<p>&gt; a = c(1,2,3)<br />
&gt; a[4]<br />
[1] NA<br />
&gt; a[-4]<br />
[1] 1 2 3</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David MacKay</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-167</link>
		<dc:creator><![CDATA[David MacKay]]></dc:creator>
		<pubDate>Fri, 26 Sep 2008 01:04:05 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-167</guid>
		<description><![CDATA[&gt; a[HA]
[1] HA HA HA HA HA

 I&#039;m reminded of the useful conversational elements in the English-Spanish phrase book.
Do you speak Norwegian?
 ...
Does anyone here speak Norwegian?
 ...
I don&#039;t speak Norwegian.]]></description>
		<content:encoded><![CDATA[<p>&gt; a[HA]<br />
[1] HA HA HA HA HA</p>
<p> I&#8217;m reminded of the useful conversational elements in the English-Spanish phrase book.<br />
Do you speak Norwegian?<br />
 &#8230;<br />
Does anyone here speak Norwegian?<br />
 &#8230;<br />
I don&#8217;t speak Norwegian.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radford Neal</title>
		<link>http://radfordneal.wordpress.com/2008/09/21/design-flaws-in-r-3-%e2%80%94-zero-subscripts/#comment-166</link>
		<dc:creator><![CDATA[Radford Neal]]></dc:creator>
		<pubDate>Thu, 25 Sep 2008 19:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://radfordneal.wordpress.com/?p=503#comment-166</guid>
		<description><![CDATA[I think something got absorbed by the blog software in the above post.  I that that to enter a less-than sign, you need to use ampersand, &quot;l&quot;, &quot;t&quot;, semicolon.  I&#039;ll try it here: &lt;

Unfortunately, there seems to be no way to edit comments after they&#039;re submitted, even for me when moderating them.]]></description>
		<content:encoded><![CDATA[<p>I think something got absorbed by the blog software in the above post.  I that that to enter a less-than sign, you need to use ampersand, &#8220;l&#8221;, &#8220;t&#8221;, semicolon.  I&#8217;ll try it here: &lt;</p>
<p>Unfortunately, there seems to be no way to edit comments after they&#8217;re submitted, even for me when moderating them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
