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

<channel>
	<title>R Programming &#8211; Nick Swan&#039;s Blog</title>
	<atom:link href="http://nickswan.net/category/r-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://nickswan.net</link>
	<description>The harder I work, the luckier I get</description>
	<lastBuildDate>Wed, 27 Jan 2016 09:06:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.7.2</generator>
	<item>
		<title>Drawing a simple line graph with 2 lines : R Programming</title>
		<link>http://nickswan.net/drawing-a-simple-line-graph-with-2-lines-r-programming/</link>
					<comments>http://nickswan.net/drawing-a-simple-line-graph-with-2-lines-r-programming/#respond</comments>
		
		<dc:creator><![CDATA[nickswan]]></dc:creator>
		<pubDate>Wed, 27 Jan 2016 09:05:09 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[R Programming]]></category>
		<guid isPermaLink="false">http://nickswan.net/?p=100</guid>

					<description><![CDATA[Problem: In our last post we read in the historical share information about a company, in this post I want to plot the daily share volume amounts against a line indicating the average volume. Solution: &#62; df &#60;- read.csv(&#8216;tesco.txt&#8217;) &#62; str(df)  #look at the structure of the dataframe If you look at the data type &#8230; <a href="http://nickswan.net/drawing-a-simple-line-graph-with-2-lines-r-programming/" class="more-link">Continue reading<span class="screen-reader-text"> "Drawing a simple line graph with 2 lines : R Programming"</span></a>]]></description>
										<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>In our last post we read in the historical share information about a company, in this post I want to plot the daily share volume amounts against a line indicating the average volume.</p>
<p><strong>Solution:</strong></p>
<p>&gt; df &lt;- read.csv(&#8216;tesco.txt&#8217;)<br />
&gt; str(df)  #look at the structure of the dataframe</p>
<p>If you look at the data type of X.date you will see it is an int. We want to convert this to a proper datetime. I had a few issues with this, and it seems to be as it has been read in as an int when you try to convert it, it thinks it is a milliseconds value. I got around this by first converting the int to a char</p>
<p>&gt; df$X.date = as.Date(as.character(df$X.date), &#8220;%Y%m%d&#8221;) #convert to date<br />
&gt; df$X.Avg &lt;- mean(df$X.vol.) #create a new column and store the average volume<br />
&gt; plot(df$X.date,df$X.vol, type=&#8221;l&#8221;) #draw a line graph, l is for line<br />
&gt; lines(df$X.date,df$X.Avg, col=&#8221;red&#8221;)</p>
<p><a href="http://nickswan.net/wp-content/uploads/2016/01/tesco-graph.jpg"><img loading="lazy" class="aligncenter size-full wp-image-101" src="http://nickswan.net/wp-content/uploads/2016/01/tesco-graph.jpg" alt="tesco-graph" width="530" height="458" srcset="http://nickswan.net/wp-content/uploads/2016/01/tesco-graph.jpg 530w, http://nickswan.net/wp-content/uploads/2016/01/tesco-graph-300x259.jpg 300w" sizes="(max-width: 530px) 85vw, 530px" /></a></p>
<p>It would be nice to get the axis names sorted out, and the formatting of the numbers.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>http://nickswan.net/drawing-a-simple-line-graph-with-2-lines-r-programming/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Reading text files and getting a column&#8217;s average value : R Programming</title>
		<link>http://nickswan.net/reading-text-files-and-getting-a-columns-average-value-r-programming/</link>
					<comments>http://nickswan.net/reading-text-files-and-getting-a-columns-average-value-r-programming/#respond</comments>
		
		<dc:creator><![CDATA[nickswan]]></dc:creator>
		<pubDate>Tue, 26 Jan 2016 16:17:40 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[R Programming]]></category>
		<guid isPermaLink="false">http://nickswan.net/?p=99</guid>

					<description><![CDATA[Problem: Before doing anything interesting in R, we need to have some data to play with. I want to read in a list of End of Day prices for a company, and working out the average volume of that share traded. This solution is going to require an account on www.eoddata.com to get access to the &#8230; <a href="http://nickswan.net/reading-text-files-and-getting-a-columns-average-value-r-programming/" class="more-link">Continue reading<span class="screen-reader-text"> "Reading text files and getting a column&#8217;s average value : R Programming"</span></a>]]></description>
										<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Before doing anything interesting in R, we need to have some data to play with. I want to read in a list of End of Day prices for a company, and working out the average volume of that share traded.</p>
<p>This solution is going to require an account on www.eoddata.com to get access to the historical close prices of a share.</p>
<p><strong>Solution:</strong></p>
<p>I&#8217;ve downloaded the close prices for Tesco and placed them in /users/nick/rdata<br />
This is the code to read in the text file and calculate the average volume of shares traded:</p>
<p>&gt; setwd(&#8216;/users/nick/rdata&#8217;)  # set the working directory<br />
&gt; df &lt;- read.csv(&#8216;tesco.txt&#8217;)<br />
&gt; mean(df$X.vol)<br />
[1] 22283443</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>http://nickswan.net/reading-text-files-and-getting-a-columns-average-value-r-programming/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Learning R Programming : The Tutorials</title>
		<link>http://nickswan.net/learning-r-programming-the-tutorials/</link>
					<comments>http://nickswan.net/learning-r-programming-the-tutorials/#respond</comments>
		
		<dc:creator><![CDATA[nickswan]]></dc:creator>
		<pubDate>Tue, 26 Jan 2016 16:07:57 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[R Programming]]></category>
		<guid isPermaLink="false">http://nickswan.net/?p=98</guid>

					<description><![CDATA[I&#8217;ve been trying to learn the programming language R for a couple of months now, and while following the course datacamp.com has been good &#8211; it is only by doing real (useful) tasks that I feel I can move my knowledge forward enough to be ready to tackle some machine learning competitions on Kaggle. Back &#8230; <a href="http://nickswan.net/learning-r-programming-the-tutorials/" class="more-link">Continue reading<span class="screen-reader-text"> "Learning R Programming : The Tutorials"</span></a>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been trying to learn the programming language R for a couple of months now, and while following the course <a href="https://www.datacamp.com/">datacamp.com</a> has been good &#8211; it is only by doing real (useful) tasks that I feel I can move my knowledge forward enough to be ready to tackle some machine learning competitions on <a href="https://www.kaggle.com/">Kaggle</a>.</p>
<p>Back in the day, when transitioning over from VB6 to VB.net, a really useful book that helped me along was <a href="http://www.amazon.co.uk/gp/product/159059021X">Karl Moores Visual Basic.Net : The Tutorials</a> (I even wrote an Amazon review for it &#8211; it really must have been good!!!)</p>
<p>My plan is to develop something like this as a set of blog posts, where each posts outlines a problem &#8211; with the solution after. I have no doubt that some of the solutions will be suboptimal &#8211; but that&#8217;s where I hope the interweb will come in handy and help me improve my knowledge.</p>
<p>Lets see how it goes. Here are the topics covered to far.</p>
<p><a href="http://nickswan.net/2016/01/26/reading-text-files-and-getting-a-columns-average-value-r-programming/">Reading in a text file and getting the average of a column</a></p>
<p><a href="http://nickswan.net/2016/01/27/drawing-a-simple-line-graph-with-2-lines-r-programming/">Drawing a simple line graph with 2 lines</a></p>
]]></content:encoded>
					
					<wfw:commentRss>http://nickswan.net/learning-r-programming-the-tutorials/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using disk: enhanced 

Served from: nickswan.net @ 2021-05-17 01:12:24 by W3 Total Cache
-->