<?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>Dang, another error</title>
	<atom:link href="http://danganothererror.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://danganothererror.wordpress.com</link>
	<description>K-means no.</description>
	<lastBuildDate>Sat, 15 Jan 2011 20:28:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='danganothererror.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Dang, another error</title>
		<link>http://danganothererror.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://danganothererror.wordpress.com/osd.xml" title="Dang, another error" />
	<atom:link rel='hub' href='http://danganothererror.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Adding lines or points to an existing barplot</title>
		<link>http://danganothererror.wordpress.com/2011/01/15/adding-lines-or-points-to-an-existing-barplot/</link>
		<comments>http://danganothererror.wordpress.com/2011/01/15/adding-lines-or-points-to-an-existing-barplot/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 20:28:49 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[barp]]></category>
		<category><![CDATA[barplot]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[plotrix]]></category>
		<category><![CDATA[points]]></category>
		<category><![CDATA[r]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=123</guid>
		<description><![CDATA[Sometimes you will need  to add some points to an existing barplot. You might try but you will get a funky looking line/points. It&#8217;s a bit squeezed. This happens because bars are not drawn at intervals 1:10, but rather on something else. This &#8220;else&#8221; can be seen if you save your barplot object. You will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=123&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you will need  to add some points to an existing barplot. You might try</p>
<p><pre class="brush: python;">par(mfrow = c(1,2))
df &lt;- data.frame(stolpec1 = 10 * runif(10), stolpec2 = 30 * runif(10))
barplot(df$stolpec1)
lines(df$stolpec2/10) #implicitno x = 1:10
points(df$stolpec2/10) </pre></p>
<p>but you will get a funky looking line/points. It&#8217;s a bit squeezed. This happens because bars are not drawn at intervals 1:10, but rather on something else. This &#8220;else&#8221; can be seen if you save your barplot object. You will notice that it&#8217;s a matrix object with one column &#8211; these are values that are assumed on x axis. Now you need to feed this to your lines/points function as a value to x argument and you&#8217;re all set.</p>
<p><pre class="brush: python;">

df.bar &lt;- barplot(df$stolpec1)
lines(x = df.bar, y = df$stolpec2/10)
points(x = df.bar, y = df$stolpec2/10)</pre></p>
<p><a href="http://danganothererror.files.wordpress.com/2011/01/barplot_lines_points.png"><img class="aligncenter size-full wp-image-126" title="barplot_lines_points" src="http://danganothererror.files.wordpress.com/2011/01/barplot_lines_points.png?w=600&#038;h=300" alt="" width="600" height="300" /></a></p>
<p>Another way of plotting this is using plotrix package. The controls are a bit different and it takes some time getting used to it.</p>
<p><pre class="brush: python;">

library(plotrix)

barp(df$stolpec1, col = &quot;grey70&quot;)
lines(df$stolpec2/10)
points(df$stolpec2/10)

</pre></p>
<p><a href="http://danganothererror.files.wordpress.com/2011/01/plotrix.png"><img class="aligncenter size-full wp-image-131" title="plotrix" src="http://danganothererror.files.wordpress.com/2011/01/plotrix.png?w=600" alt=""   /></a></p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=123&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2011/01/15/adding-lines-or-points-to-an-existing-barplot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>

		<media:content url="http://danganothererror.files.wordpress.com/2011/01/barplot_lines_points.png" medium="image">
			<media:title type="html">barplot_lines_points</media:title>
		</media:content>

		<media:content url="http://danganothererror.files.wordpress.com/2011/01/plotrix.png" medium="image">
			<media:title type="html">plotrix</media:title>
		</media:content>
	</item>
		<item>
		<title>Modeling sound pressure level of a rifle shot</title>
		<link>http://danganothererror.wordpress.com/2010/11/01/92/</link>
		<comments>http://danganothererror.wordpress.com/2010/11/01/92/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 07:45:17 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[sound pressure level]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[dB]]></category>
		<category><![CDATA[rifle]]></category>
		<category><![CDATA[shooting range]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=92</guid>
		<description><![CDATA[Noise can be classified as pollution and lawmakers often (always?) treat it as such. Noise can have different origin points, point source being among the simplest to model. Because noise has broader health implications, being able to understand its propagation, a simple model can further our understanding in toning down or preventing excessive noise burden [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=92&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Noise can be classified as pollution and lawmakers often (always?) treat it as such. Noise can have different origin points, point source being among the simplest to model. Because noise has broader health implications, being able to understand its propagation, a simple model can further our understanding in toning down or preventing excessive noise burden on the environment and its inhabitants. In this work, I will focus on firing range noise and the propagation of sound to the surrounding area.<br />
Small scale firing ranges can be considered as point origin of noise. To make a simple predictive model, a number of assumptions and generalization are made. The reader should realize that this makes the model a bit less realistic.</p>
<p>When talking to experienced people, they will tell you that the distance between a firing range and the first house should be roughly 200 m. While there is no explicit mention of this number in Slovenian laws (yes, I&#8217;ve checked), there is a threshold of sound pressure level (SPL) of 75 dB. So, knowing the SPL of the rifle and we know the legal threshold, we can use a simple model to estimate approximate distance at which the SPL will fall to or below the aforementioned legal threshold.</p>
<p>A rifle shot produces a sound pressure level of about 170 dB, which is roughly the sound of a jet engine at a 30 m distance (see <a href="http://en.wikipedia.org/wiki/Sound_pressure">here</a>).</p>
<p>Noise propagates and dissipates through the air with roughly (<a href="http://www.sengpielaudio.com/calculator-distance.htm">source</a>)</p>
<p><pre class="brush: python;">p ~ 1/r</pre></p>
<p>which gives us</p>
<p><pre class="brush: python;">

L_2 = L_1 - 20 × log(r_2/r_1)

</pre></p>
<p>where</p>
<p>L_2 = sound level at  measured distance<br />
L_1 = sound level at reference distance<br />
r_1 = reference distance from source of the sound<br />
r_2 = measured distance from the source</p>
<p>Using this model, we have accepted all sorts of assumptions, like calm weather, even terrain, even air pressure, no air resistance&#8230; Come to think of it, this model would be best suited for a desert in lovely weather. Nonetheless, it gives us a starting point.</p>
<p>I would be interested to hear from more knowledgeable readers on any potential mistakes and how to improve the model with regards to at least  above assumptions.</p>
<p>Modeling this equation in R is trivial. Let&#8217;s write a function that will calculate L_2 for a sequence of r_2 values.</p>
<p><pre class="brush: python;">

soundPressure &lt;- function(r2, r1, L1) {
 L2 &lt;- L1 - 20 * log(r1/r2)
 dL &lt;- L1 - abs(L1 - L2) # this will give us the appropriate delta that we can use to plot our graph
 return(dL)
}

# let's define some parameters
distance &lt;- seq(1, 1000, 1) # a vector of distances to be used as r_2
L1 &lt;- 170
r1 &lt;- 1

# this is the threshold level defined by the lawmaker
# we're actually interested in finding at what distance, the noise
# dissipates to this level
dB.level &lt;- 75

# apply the above formula to every value in &quot;distance&quot;
dB &lt;- sapply(distance, soundPressure, r1 = r1, L1 = L1)

# plotting
find.x &lt;- which(round(dB) == dB.level)[1] # find which value is ~75 dB

plot(x = distance, y = dB, ylim = c(1, L1), xlab = &quot;Distance (m)&quot;,
 ylab = &quot;Sound pressure level (dB)&quot;, type = &quot;l&quot;)
abline(h = dB.level, col = &quot;red&quot;)
abline(v = find.x, col = &quot;red&quot;)
# distance label
text(x = distance[find.x], y = 0, offset = 0.5, col = &quot;black&quot;,
 pos = 4, labels = paste(distance[find.x], &quot;m&quot;), cex = 1.3)
# SPL
text(x = 0, y = dB.level, col = &quot;black&quot;, labels = paste(dB.level, &quot;dB&quot;),
 cex = 1.3, offset = 1, pos = 1)

</pre></p>
<p>Result of the plotting is<br />
<a href="http://danganothererror.files.wordpress.com/2010/11/pok1.png"><img class="aligncenter size-full wp-image-113" title="pok" src="http://danganothererror.files.wordpress.com/2010/11/pok1.png?w=600" alt=""   /></a><a href="http://danganothererror.files.wordpress.com/2010/11/pok.png"><br />
</a>This tells us that the sound pressure level at roughly 113 m away from the rifle will be 75 dB (the legal threshold). Based on these results, a 200 m buffer around a firing range gives an estimate with a margin of around 100 m buffer.</p>
<p>As already mentioned, I would be happy to hear your comments on errors and how to improve the above model.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=92&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/11/01/92/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>

		<media:content url="http://danganothererror.files.wordpress.com/2010/11/pok1.png" medium="image">
			<media:title type="html">pok</media:title>
		</media:content>
	</item>
		<item>
		<title>Dump R datasets into a single file</title>
		<link>http://danganothererror.wordpress.com/2010/08/22/dump-r-datasets-into-a-single-file/</link>
		<comments>http://danganothererror.wordpress.com/2010/08/22/dump-r-datasets-into-a-single-file/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 22:23:52 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[datasets]]></category>
		<category><![CDATA[export]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=83</guid>
		<description><![CDATA[Should you need datasets that come with R and additional packages (you can access them via data()) in one single file, here&#8217;s what I did to dump the entire workspace into one file: This code can easily be adapted to dump individual dataset into its own file.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=83&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Should you need datasets that come with R and additional packages (you can access them via data()) in one single file, here&#8217;s what I did to dump the entire workspace into one file:</p>
<p><pre class="brush: python;">

rm(list=ls())
data(list = data()$results[, 3])  # put datasets into your global environment
sink(&quot;datasets.txt&quot;)
for (i in 1:length(ls())) {
 cat(&quot;*****************&quot;, &quot;\n&quot;)
 print(ls()[i])
 cat(&quot;*****************&quot;, &quot;\n&quot;)
 print(get(ls()[i]))
 cat(&quot;\n&quot;)
}
sink()

</pre></p>
<p>This code can easily be adapted to dump individual dataset into its own file.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=83&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/08/22/dump-r-datasets-into-a-single-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>
	</item>
		<item>
		<title>Bootstrap, strap-on, anal-yzing&#8230; statistics is getting weirder by the moment</title>
		<link>http://danganothererror.wordpress.com/2010/07/29/bootstrap-strap-on-anal-yzing-statistics-is-getting-weirder-by-the-moment/</link>
		<comments>http://danganothererror.wordpress.com/2010/07/29/bootstrap-strap-on-anal-yzing-statistics-is-getting-weirder-by-the-moment/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 18:01:17 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
		
		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=40</guid>
		<description><![CDATA[I have spent the better portion of the day trying to get a bootstrap working. I have adapter a pre-written bootstrap function, but I wanted to use a generic function, mostly for reaping fame and glory. My hypothesis was that writing a hand-written, unoptimized function will consume more computer time than the generic, presumably optimized, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=40&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have spent the better portion of the day trying to get a bootstrap working. I have adapter a pre-written bootstrap function, but I wanted to use a generic function, mostly for reaping fame and glory. My hypothesis was that writing a hand-written, unoptimized function will consume more computer time than the generic, presumably optimized, boot() function. Was I wrong!</p>
<p>In this example, I random sample (with replacement) a vector of n values and store them in a matrix. These values that are written to the matrix are percent of values of our initial vector values that are smaller or equal to the bin number (see the code). Once we&#8217;ve got all the values, we can calculate the median by columns for further tinkering. There&#8217;s a lot of material covering bootstrapping on the Internet, but for a quick reference, see <a href="http://en.wikipedia.org/wiki/Bootstrapping">this Wikipedia entry</a>. At <a href="http://stackoverflow.com/questions/3355784/help-me-improve-my-bootstrap">this StackOverflow thread</a>, Aniko provided me with valuable information on what I was doing wrong.</p>
<p>This is the code I used &#8211; first part is the hand written function, and the second part is my attempt at cracking the matter with a generic function.</p>
<p><pre class="brush: python;">require(Hmisc)

#generate fake data
data &lt;- rchisq(500, df = 12)

#create bins
binx &lt;- cut(data, breaks = 10)
binx &lt;- levels(binx)
binx &lt;- sub(&quot;^.*\\,&quot;, &quot;&quot;, binx)
binx &lt;- as.numeric(substr(binx, 1, nchar(binx) - 1))

#pre-allocate a matrix to be filled with samples
num.boots &lt;- 10
output &lt;- matrix(NA, nrow = num.boots, ncol = length(binx))

#do random sampling from the vector and calculate percent
#of values equal or smaller to the bin number (i)

for (i in 1:num.boots) {
 data.sample &lt;- sample(data, size = length(data), replace = TRUE)
 data.cut &lt;- cut(x = data.sample, breaks = 10)
 data.cut &lt;- table(data.cut)/sum(table(data.cut))
 output[i, ] &lt;- data.cut
}

#do some plotting
plot(1:10, seq(0, max(output), length.out = nrow(output)), type = &quot;n&quot;, xlab = &quot;&quot;, ylab = &quot;&quot;)

for (i in 1:nrow(output)) {
 lines(1:10, output[i, 1:nrow(output)], lwd = &quot;0.5&quot;)
}
output.median &lt;- apply(output, 2, median)
output.sd &lt;- apply(output, 2, sd)
sd.up &lt;- output.median + output.sd * 1.96
sd.down &lt;- output.median - output.sd * 1.96

lines(output.median, col=&quot;red&quot;, lwd = 3)
lines(sd.up, lty=&quot;dashed&quot;, col=&quot;green&quot;)
lines(sd.down, lty=&quot;dashed&quot;, col=&quot;green&quot;)
legend(x = 8, y = 0.25, legend = c(&quot;median&quot;, &quot;0.95% CI&quot;), col = c(&quot;red&quot;, &quot;green&quot;), lty = c(&quot;solid&quot;, &quot;dashed&quot;), lwd = c(3, 1))</pre></p>
<p>All this produces this graph.</p>
<div id="attachment_43" class="wp-caption aligncenter" style="width: 490px"><a href="http://danganothererror.files.wordpress.com/2010/07/bootstrap.png"><img class="size-full wp-image-43 " title="bootstrap" src="http://danganothererror.files.wordpress.com/2010/07/bootstrap.png?w=600" alt=""   /></a><p class="wp-caption-text">Click to enlarge (the picture).</p></div>
<p>We can then try the power of the generic boot::boot() function that comes with the R core packages. The fun part of doing a bootstraping with the boot() function is to figure out how to write the statistic function correctly. If you look at the boot() help page (?boot) you will notice that you need to provide at least two parameters to the statistic argument: data and an index parameter. Help page says that the index parameter is a vector, which is a bit confusing from where I sit. In other words, this is actually a &#8220;an empty object&#8221; (let&#8217;s call the object i for now) that tells the boot() how to crawl over your data. If your data is in a form of a vector, you will place the index as you would use to subset a vector &#8211; object[i]. If it&#8217;s a data.frame and you want to re-sample rows, you would call  object[i, ]&#8230; Let&#8217;s see a working example, things may be clearer there.</p>
<p><pre class="brush: python;">
pairboot &lt;- function(data, i, binx) {
 data.cut &lt;- cut(x = data[i], breaks = 10)
 data.cut &lt;- table(data.cut)/sum(table(data.cut))
 return(data.cut)
}</pre></p>
<p>Notice the data[i] in the function. This will tell the boot() function to extract i elements of the data. If we had a data.frame, and rows were what we wanted to sample randomly, we would have written data[i, ].<br />
And now we call the boot function to perform 10 &#8220;boots&#8221; on our data.</p>
<p><pre class="brush: python;">library(boot)
booty.call &lt;- boot(data = data, statistic = pairboot, R = 10, binx = binx)</pre></p>
<p>And here is the code to plot the output of the boot object (actually, it&#8217;s the print.boot object!). If you don&#8217;t believe me, try it on your own and see if you get a similar picture as above.</p>
<p><pre class="brush: python;">plot(1:10, seq(0, 1.5 * max(booty.call$t0), length.out = nrow(booty.call$t)), type = &quot;n&quot;, xlab = &quot;&quot;, ylab = &quot;&quot;)
apply(booty.call$t, 1, function(x) lines(x, lwd = 0.5))
booty.call.median &lt;- apply(booty.call$t, 2, median)
booty.call.sd &lt;- apply(booty.call$t, 2, sd)
booty.call.sd.up &lt;- booty.call.median + booty.call.sd * 1.96
booty.call.sd.down &lt;- booty.call.median - booty.call.sd * 1.96
lines(booty.call.median, col=&quot;red&quot;, lwd = 3)
lines(booty.call.sd.up, lty=&quot;dashed&quot;, col=&quot;green&quot;)
lines(booty.call.sd.down, lty=&quot;dashed&quot;, col=&quot;green&quot;)
legend(x = 8, y = 0.25, legend = c(&quot;median&quot;, &quot;0.95% CI&quot;), col = c(&quot;red&quot;, &quot;green&quot;), lty = c(&quot;solid&quot;, &quot;dashed&quot;), lwd = c(3, 1))</pre></p>
<p>The plot thickens!</p>
<p>Have I, by doing a bootstrap with a generic function, profited time-wise at all? Here are the elapse times for 10000 iterations for our hand written bootstrap function and the generic, respectively.</p>
<p><pre class="brush: python;">
# user  system elapsed
#20.045   0.664  22.821
</pre></p>
<p><pre class="brush: python;">
# user  system elapsed
#20.382   0.612  22.097
</pre></p>
<p>So you can see, I profit by 0.724 seconds. Was it worth it? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I can, for the moment, only wonder if I could improve the generic function to beat the hand-written one. Does anyone skilled in optimizing chip in any tips?</p>
<p>And here&#8217;s how a graph with 10000 iterations looks like. The green dashed lines represent a 95% confidence interval, which means that 95% of iterations fall between those two lines.</p>
<p><div id="attachment_57" class="wp-caption aligncenter" style="width: 490px"><a href="http://danganothererror.files.wordpress.com/2010/07/boot10k.png"><img class="size-full wp-image-57 " title="boot10k" src="http://danganothererror.files.wordpress.com/2010/07/boot10k.png?w=600" alt=""   /></a><p class="wp-caption-text">Bootstrap with 10000 iterations. CI is confidence interval.</p></div></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=40&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/07/29/bootstrap-strap-on-anal-yzing-statistics-is-getting-weirder-by-the-moment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>

		<media:content url="http://danganothererror.files.wordpress.com/2010/07/bootstrap.png" medium="image">
			<media:title type="html">bootstrap</media:title>
		</media:content>

		<media:content url="http://danganothererror.files.wordpress.com/2010/07/boot10k.png" medium="image">
			<media:title type="html">boot10k</media:title>
		</media:content>
	</item>
		<item>
		<title>How to calculate with dates and hours in R</title>
		<link>http://danganothererror.wordpress.com/2010/07/24/how-to-calculate-with-dates-and-hours-in-r/</link>
		<comments>http://danganothererror.wordpress.com/2010/07/24/how-to-calculate-with-dates-and-hours-in-r/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 11:49:48 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[datum]]></category>
		<category><![CDATA[difftime]]></category>
		<category><![CDATA[POSIXct]]></category>
		<category><![CDATA[POSIXlt]]></category>
		<category><![CDATA[strptime]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=28</guid>
		<description><![CDATA[A while ago I was asked whether calculating with datums and hours is possible in R. Especially, if you added an hours to 23:45 (say Jan 1, 2010) , would R know to jump to the next day &#8211; 00:45 (jan 2, 2010)? The answer is yes. Our only job is to tell R in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=28&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A while ago I was asked whether calculating with datums and hours is possible in R. Especially, if you added an hours to 23:45 (say Jan 1, 2010) , would R know to jump to the next day &#8211; 00:45 (jan 2, 2010)? The answer is yes. Our only job is to tell R in what format our datum and time is. After we have done so, we can use these datums and times for different calculations.</p>
<p>Let&#8217;s say we have a vector (or any other object type) with datum and hour:</p>
<p><pre class="brush: python;">1.1.2010 11:35</pre></p>
<p>We need to tell R that this is in fact a POSIX type object, whereas we need to specify which number corresponds to what. We will tell it that the first number is day, followed by a dot (.), followed by a month, followed by a dot&#8230; You get the picture. This is done through the format argument.</p>
<p><pre class="brush: python;">dtm &lt;- strptime(c(&quot;1.1.2010 11:35&quot;), format = &quot;%d.%m.%Y %H:%M&quot;, tz = &quot;CET&quot;)</pre></p>
<p>While the inclusion of tz argument (time zone) is not applicable here, be careful if you&#8217;re calculating with datums and times from different time zones. For the following examples, I&#8217;ve added another element to the vector to spice things up.</p>
<p><pre class="brush: python;">&gt; dtm
[1] &quot;2010-01-01 11:35:00 CET&quot; &quot;2010-02-01 08:45:00 CET&quot;
&gt; str(dtm)
 POSIXlt[1:9], format: &quot;2010-01-01 11:35:00&quot; &quot;2010-02-01 08:45:00&quot;</pre></p>
<p>For pedagogic purposes, I will make things a wee more complicated (at least for novice). Let&#8217;s write two simple (and I mean SIMPLE) yet not mandatory functions that will convert hours and minutes to seconds. Because calculating with POSIX objects is done via seconds (see below), by using these functions we free ourselves from typing 3 * 3600 every time we want to use 3 hours or 3*60 for 3 minutes. At least in my view, this makes the code (where we calculate) a bit more readable.</p>
<p>Here are the two functions:</p>
<p><pre class="brush: python;">hrs &lt;- function(u) {
 x &lt;- u * 3600
 return(x)
}

mns &lt;- function(m) {
 x &lt;- m * 60
 return(x)
}</pre></p>
<p>This will add three hours to the current date/time values in dtm</p>
<p><pre class="brush: python;">&gt; dtm + hrs(3)
[1] &quot;2010-01-01 14:35:00 CET&quot; &quot;2010-02-01 11:45:00 CET&quot;</pre></p>
<p>This will add 3 hours and 10 minutes.</p>
<p><pre class="brush: python;">&gt; dtm + hrs(3) + mns(10)
[1] &quot;2010-01-01 14:45:00 CET&quot; &quot;2010-02-01 11:55:00 CET&quot;</pre></p>
<p>If we hadn&#8217;t used our functions, our input would look like this</p>
<p><pre class="brush: python;">&gt; dtm + 3*3600 + 10*60
 [1] &quot;2010-01-01 14:45:00 CET&quot; &quot;2010-02-01 11:55:00 CET&quot;</pre></p>
<p>See, I told you hrs() and mns() is more intuitive. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>We can also subtract. Let&#8217;s cut off 111 seconds</p>
<p><pre class="brush: python;">&gt; dtm - 111
[1] &quot;2010-01-01 11:33:09 CET&quot; &quot;2010-02-01 08:43:09 CET&quot;</pre></p>
<p>We are interested if datum will change if we add enough hours (or minutes). Let&#8217;s add 15 hours.</p>
<p><pre class="brush: python;">&gt; dtm + hrs(15)
[1] &quot;2010-01-02 02:35:00 CET&quot; &quot;2010-02-01 23:45:00 CET&quot;</pre></p>
<p>No surprises there &#8211; first element changed to the next day and the seconds element fell short for 15 minutes.</p>
<p>If we&#8217;re curious how far apart are two datums, we use the following function:</p>
<p><pre class="brush: python;">&gt; difftime(dtm2[1], dtm2[2])
Time difference of -30.88194 days</pre></p>
<p>All this and more can be also found in The R Book by Michael J. Crawley. This particular chapter can be accessed <a href="http://books.google.com/books?id=8D4HVx0apZQC&amp;pg=PA90&amp;lpg=PA89" target="_blank">through the web</a>. Data manipulations with R by Phil Specter can in part be previewed <a href="http://books.google.com/books?id=grfuq1twFe4C&amp;printsec=frontcover&amp;dq=data+manipulation+with+r&amp;source=bl&amp;ots=mq1CR6QKRB&amp;sig=HgwsLMdAFstW_p9GDXUOKpinMVs&amp;hl=en&amp;ei=8J5NTPueLYmtOMTxhZYD&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=3&amp;ved=0CCIQ6AEwAg#v=onepage&amp;q&amp;f=false" target="_blank">here</a> (kudos to aL3xa for pointing it out). Help pages on datums and time classes can be found in</p>
<p><pre class="brush: python;">?DateTimeClasses</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=28&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/07/24/how-to-calculate-with-dates-and-hours-in-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>
	</item>
		<item>
		<title>Building an R package (under Windows) without C, C++ or FORTRAN code</title>
		<link>http://danganothererror.wordpress.com/2010/07/23/building-an-r-package-under-windows-without-c-c-or-fortran-code/</link>
		<comments>http://danganothererror.wordpress.com/2010/07/23/building-an-r-package-under-windows-without-c-c-or-fortran-code/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 14:31:27 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[r]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[description]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[strawberry]]></category>
		<category><![CDATA[chm help]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[cran]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=14</guid>
		<description><![CDATA[Why build and R package? It basically boils down to be able to brag at your local pub that a new version of YOUR package is on CRAN as of 7 p.m. CET. But seriously, if you&#8217;ve produced some function that other people might benefit (or have ordered them) from using them, like your boss, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=14&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Why build and R package? It basically boils down to be able to brag at your local pub that a new version of YOUR package is on CRAN as of 7 p.m. CET. But seriously, if you&#8217;ve produced some function that other people might benefit (or have ordered them) from using them, like your boss, co-workers or students, consider building a package. The chances of broken dependencies and ease of installing everything outweighs the effort of learning how to build one. If you feel your functions (that may be new in some respect) could benefit an even wider audience, consider submitting it to CRAN (I will not discuss how to do that here, but do read the Ripley reference I mention later).</p>
<p>I  have set out to build a test package to prepare myself when the time  comes and will really need to build one of my own. This here is an attempt I made to  document steps I took when building a dummy package (called texasranger  (yes, THE Texas Ranger!)) with one single function. I have attempted to  build documentation and all other ladeeda things that are mandatory for the package to  check out O.K. when building it.</p>
<p>Before you dig into the actual preparation and building itself, you  will need a bunch of tools. These come in a bag with a linux  distribution, but you will have to add them yourself if you&#8217;re on  Windows. This is basically the only thing that is different when trying  to build a package on Windows/Linux. I will not go into details  regarding these tools (perl, MS html help compiler, if you have  C/C++/FORTRAN code you will need GNU compiler set) , a TeX distro), &#8211; I  will, however, advise you to check out <a href="http://faculty.chicagobooth.edu/peter.rossi/research/bayes%20book/bayesm/Making%20R%20Packages%20Under%20Windows.pdf" target="_blank">Making R package under Windows</a> (P. Rossi). There, you will find  a detailed description (see page 2-6) of how to proceed to get all the  correct tools and how to set them up.  When you have done so, you are  invited to come back here. Feel free to follow just mentioned tutorial,  as it goes a bit more in-depth with explaining various aspects. The author warns that <a href="http://miktex.org/" target="_blank">MiKTeX</a> will not work (see the datum of the  document), but things might have changed since then and it now works, at  least for me.</p>
<p>I have followed the  aforementioned <a href="http://faculty.chicagobooth.edu/peter.rossi/research/bayes%20book/bayesm/Making%20R%20Packages%20Under%20Windows.pdf" target="_blank">Making R package under Windows</a> (by P. Rossi),  slides <a href="http://www.stats.ox.ac.uk/%7Eruth/RCourse/Rcourse104up.pdf" target="_blank">Making an R package</a> made by R.M. Ripley and of course  the now famous <a href="http://cran.r-project.org/doc/manuals/R-exts.pdf" target="_blank">Writing  R Extensions</a> (WRE) by R dev core team (you are referred to this document everywhere). I would advise everyone to  read them in this listed order &#8211; or at least read WRE last. First two can be read from cover to cover in a  few minutes &#8211; the last one is a good reference document for those pesky  &#8220;details&#8221;. In my experience, I started to appreciate WRE only after I  have read the first two documents.</p>
<p>Enough chit-chat, let&#8217;s get cracking!</p>
<p>1. These are the paths I  entered (see document by Rossi what this is all about) to enable all  the tools so that I can access them from the Command prompt (Command  prompt can be found under Accessories, another term for it may be Terminal or  Console on different OSs):</p>
<p><pre class="brush: plain;">c:/rtools/bin;c:/program files/miktex 2.8/miktex/bin;c:/program  files/ghostgum/gsview;C:/strawberry/perl/bin;c:/program  files/r/r-2.11.0/bin;c:/program files/help  workshop%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin</pre></p>
<p>2. Use R function</p>
<p><pre class="brush: python;">package.skeleton()</pre></p>
<p>to create directory structure  and some files (DESCRIPTION and NAMESPACE). I used the following  arguments:</p>
<p><pre class="brush: python;">package.skeleton(name = &quot;texasranger&quot;, list =  c(&quot;bancaMancaHuman&quot;), namespace = TRUE) #I only have one function, but you can list them more</pre></p>
<p>See argument <em>code_files</em> for an  alternative way of telling the function where to read your functions. I  suspect this may be very handy if you have each function in a separate  file.</p>
<p>3. Fill out DESCRIPTION and NAMESPACE (if you decide to have a name  space, read more @ WRE document). Pay special attention to export, import,  useDynLib&#8230; All of the above mentioned documentation   will help guide you through the process with minimal effort.<br />
A side (but important) note. You should write your functions without  them calling</p>
<p><pre class="brush: python;">require()</pre></p>
<p>or</p>
<p><pre class="brush: python;">source()</pre></p>
<p>to dig up other function and  packages. Read more about NAMESPACE and how to  specify which functions and packages to &#8220;export&#8221; (or &#8220;import&#8221;) and how.</p>
<p>4. Create  documentation files. This is said to be the trickiest part. I  still don&#8217;t have much experience with this so I can&#8217;t judge how tricky  it can be &#8211; but I can tell you that it may be time consuming. Make sure  you take time to document your functions well. If you were smart, you  wrote all this down while you were writing (or preparing to write) a  function and this should be more or less a session of copy-paste. Use</p>
<p><pre class="brush: python;">prompt(function, file = &quot;filename.Rd&quot;)</pre></p>
<p>to create template Rd files ready  for editing. They are more or less self explanatory (with plenty of instructions). It help if you know LaTeX, but not necessary. Also, I suspect the function may dump the files into the correct  /man directory automatically &#8211; if it doesn&#8217;t, do give it a hand and  move the files there yourself. Perhaps worth mentioning is that if you want to reference to functions  outside your package, use(notice the options square brackets [])</p>
<p><pre class="brush: latex;">\code{\link[package:function]{function}}</pre></p>
<p>,  e.g.</p>
<p><pre class="brush: latex;">\code{\link[raster:polygonsToRaster]{polygonsToRaster}}</pre></p>
<p>or</p>
<p><pre class="brush: latex;">\code{\link[utils:remove.packages]{remove_packages}}</pre></p>
<p>- To refer to &#8220;internal&#8221; package function (those visible by the user),  use</p>
<p><pre class="brush: latex;">\code{\link{function_name}}</pre></p>
<p>5. To check the documentation  for errors, use</p>
<p><pre class="brush: plain;">R CMD Rd2txt filename.Rd</pre></p>
<p>and/or</p>
<p><pre class="brush: plain;">R CMD Rdconv -t=html -o=filename.html filename.Rd</pre></p>
<p>6.  Next, you should run a check on your package before you build it. You  should run it from the directory where the package directory is located.  I&#8217;ve dumped my package contents to d:/workspace/texasranger/ and  executed the commands from d:/workspace/</p>
<p><pre class="brush: plain;">R CMD check</pre></p>
<p>If you get any errors, you will be  referred to the output file. READ and UNDERSTAND it.</p>
<p>7. Build the  package with the command</p>
<p><pre class="brush: plain;">R CMD build package_name</pre></p>
<p>This  will create a file and will add a version (as specified in the  DESCRIPTION file, i.e. package_name_1.0-1.tar.gz, see WRE for specifics  on package version directives).</p>
<p>package_name is actually the name of the directory (which should  be the name of your package as well).</p>
<p>If you use Windows, you  can build a .zip file AND install the package (uses install.packages) at  the same time. Use command</p>
<p><pre class="brush: plain;">R CMD INSTALL --build package_name_1.0-1.tar.gz</pre></p>
<p>8.  Rejoyce.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=14&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/07/23/building-an-r-package-under-windows-without-c-c-or-fortran-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>
	</item>
		<item>
		<title>Join the Statistical analysis Q&amp;A beta</title>
		<link>http://danganothererror.wordpress.com/2010/07/18/join-the-statistical-analysis-qa-beta/</link>
		<comments>http://danganothererror.wordpress.com/2010/07/18/join-the-statistical-analysis-qa-beta/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 07:34:42 +0000</pubDate>
		<dc:creator>danganothererror</dc:creator>
				<category><![CDATA[R buzz]]></category>

		<guid isPermaLink="false">http://danganothererror.wordpress.com/?p=7</guid>
		<description><![CDATA[Statistical Analysis Q&#38;A is a web page dedicated to exchange questions, answers and ideas primarily on statistics.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=7&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://area51.stackexchange.com/proposals/33/statistical-analysis">Statistical Analysis Q&amp;A</a> is a web page dedicated to exchange questions, answers and ideas primarily on statistics. See <a href="http://stackoverflow.com/" target="_blank">http://stackoverflow.com/</a> to get the general idea what I&#8217;m talking about. You still have a chance to sign up for closed beta testing. If you miss it, no worries mate, after about a week, it will be opened for the whole world to see.</p>
<p>See also Tal&#8217;s writing on the wall of <a href="http://www.r-statistics.com/2010/07/want-to-join-the-closed-beta-of-a-new-statistical-analysis-qa-site-now-is-the-time/" target="_blank">R-statistics blog</a>.</p>
<p>Just recently, a <a href="http://metaoptimize.com/qa" target="_blank">MetaOptimize</a> page has been launched to serve the statistical needs of people everywhere. The page has been building up steam but I&#8217;m still not sure which way it&#8217;s gonna go. I hope MO and SA will compliment each other and will not get caught in the stats feud.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danganothererror.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danganothererror.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danganothererror.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danganothererror.wordpress.com&amp;blog=14743308&amp;post=7&amp;subd=danganothererror&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danganothererror.wordpress.com/2010/07/18/join-the-statistical-analysis-qa-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d468e3582282f5e0eccf17af3a6e926?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">danganothererror</media:title>
		</media:content>
	</item>
	</channel>
</rss>
