<?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>Freigeist Blog - Jakobsweg, Pilgern und London</title>
	<atom:link href="http://freigeist.devmag.net/feed" rel="self" type="application/rss+xml" />
	<link>http://freigeist.devmag.net</link>
	<description>Gedanken über das Studium und Leben in London, die Pilgerreise auf dem Jakobsweg und das Blogging.</description>
	<lastBuildDate>Sun, 29 Jan 2012 10:55:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Removing Multibyte Characters from Strings</title>
		<link>http://freigeist.devmag.net/r/634-removing-multibyte-characters-from-strings.html</link>
		<comments>http://freigeist.devmag.net/r/634-removing-multibyte-characters-from-strings.html#comments</comments>
		<pubDate>Sun, 29 Jan 2012 10:55:32 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=634</guid>
		<description><![CDATA[I was a bit annoyed by the error when loading a dataset that contains multi-byte characters. R basically just chokes on them. I have not really understood the intricacies of this, but it was basically just an annoyance and since I did not really use these characters in the strings containing them, I just wanted [...]]]></description>
			<content:encoded><![CDATA[<p>I was a bit annoyed by the error when loading a dataset that contains multi-byte characters. R basically just chokes on them. I have not really understood the intricacies of this, but it was basically just an annoyance and since I did not really use these characters in the strings containing them, I just wanted to remove them.</p>
<p>The easiest solution was to use Vim with the following search and replace:</p>
<p><code>s/[\x80-\xFF]//g</code>
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/r/634-removing-multibyte-characters-from-strings.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/r/634-removing-multibyte-characters-from-strings.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downloading All Your Pictures From iPad or iPhone</title>
		<link>http://freigeist.devmag.net/php/610-downloading-all-your-pictures-from-ipad-or-iphone.html</link>
		<comments>http://freigeist.devmag.net/php/610-downloading-all-your-pictures-from-ipad-or-iphone.html#comments</comments>
		<pubDate>Sat, 29 Oct 2011 12:45:29 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[iPad]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=610</guid>
		<description><![CDATA[I really disklike iTunes, it is the worst piece of software I have ever come accross.  I would say that Windows has been getting better and better. I had the following problem: I uploaded quite a few pictures via iTunes onto my iPad, just because its nice to look at pictures on that machine. However, [...]]]></description>
			<content:encoded><![CDATA[<p>I really disklike iTunes, it is the worst piece of software I have ever come accross.  I would say that Windows has been getting better and better. I had the following problem: I uploaded quite a few pictures via iTunes onto my iPad, just because its nice to look at pictures on that machine. However, the machine with which I did the syncing broke and needed repair and somehow, I forgot to save these pictures onto a  hard drive for backup. So the only place where these pictures now rest is on my iPad.</p>
<p>iTunes wont allow you to copy pictures on your iPad onto a machine (only the pictures that you atually take with the iPad). This is because, these pictures *should*  be on the machine with which you synced your iPad in the first place.</p>
<p>However, this was not true in my case anymore. Now you could either invest some money and purchase an app that allows you to copy your picture albums from the iPad onto a Windows machine.</p>
<p>There is e.g. CopyTrans Suite, which is a bit costly and in the version I tried, did not copy the full resolution of the pictures (which is a rip-off!).</p>
<p>So I was looking into a cheap and quick solution to get the original full resolution pictures down from my iPad.</p>
<p><strong>Setting things up: installing free app &#8220;WiFi Photo&#8221;<br />
</strong>This app basically makes your photo albums available on a local webserver. Once you start the app on the iPad, it tells you an URL to brows to on your local machine. There you can see all the pictures that are on your iPad.</p>
<p><a href="http://itunes.apple.com/de/app/wifi-photo-transfer/"><img class="alignright" title="Logo of the Wifi Transfer app" src="http://freigeist.devmag.net/wp-content/wifi-photo-transfer-app.png" alt="Logo of the Wifi Transfer app" width="180" height="175" /></a>You could now use this app to manually download the pictures, however, it is limited to 100 pictures at once and you will not get the full resolution pictures if you do a batch download.</p>
<p>If you browse through the app, you will notice that the URL to the full resolution pictures has the following form:</p>
<p><strong>http://192.168.1.6:15555/0/fr_564.jpg</strong></p>
<p><strong></strong>where the &#8220;0&#8243; stands for the album ID. If you have, say 2 albums on the iPad, this would take values &#8220;0&#8243; or &#8220;1&#8243;. Images are stored as consecutive numbers in each album, so the following link would go to picture number 564 in full resolution in album 0. So we will exploit this structure to do an automated batch download.</p>
<p><a href="http://freigeist.devmag.net/wp-content/screenshot-wifi-transfer-app.jpg"><img class="alignnone size-full wp-image-612" title="Screnshot of the Wifi Transfer app Image Browser" src="http://freigeist.devmag.net/wp-content/screenshot-wifi-transfer-app.jpg" alt="" width="614" height="360" /></a></p>
<p><strong>Doing an automated batch download</strong></p>
<p>First, in order for this to work you need to get a a local PHP installation up and running. If you are really lazy, you could just install XAMPP. However, you can implement the code in any other coding language, e.g. in R as well.</p>
<p>To download all the pictures, you need to adjust and run the following script</p>
<div>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$k</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span><span style="color: #000088;">$k</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//adjust this</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://192.168.1.9:15555/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$k</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/fr_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//adjust this</span>
<span style="color: #000088;">$fn</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;C:/Dokumente und Einstellungen/Thiemo/Desktop/Kolumbien/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$k</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//to make sure you dont redownload a file already downloaded if you want</span>
<span style="color: #666666; font-style: italic;">//to run the script several times</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fn</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;a+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div></div>

<div>What this script does it iterates through the albums (the first loop), in my case I have four albums. The second loop then iterates through the pictures, I simply assume that there are at most 1000 pictures in each album. Clearly, this can be made smarter, i.e. automatically find out how many pictures in each album, but this works and thats all we need.</div>
<div>I would recommend running the script a few times, as sometimes it is not able to retrieve the content and then, no file is created. By adding the &#8220;file_exists&#8221; check, I make sure that no picture, that has been downloaded already, is downloaded again. So if you run the script several times, it will be quicker and quicker to also pick up the last missing pictures.</div>
</div>
<div>Running the script takes some time as it needs to copy down each picture, and in my case this were a rough 2000 pictures. But now, they are back in the safe haven of my local machine.</div>
<div><a href="http://itunes.apple.com/de/app/wifi-photo-transfer/"></p>
<p></a></div>
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/php/610-downloading-all-your-pictures-from-ipad-or-iphone.html" /></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/php/610-downloading-all-your-pictures-from-ipad-or-iphone.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Connection Sharing via Ad-Hoc network for iPhone and iPad</title>
		<link>http://freigeist.devmag.net/tricks/607-internet-connection-sharing-via-ad-hoc-network-for-iphone-and-ipad.html</link>
		<comments>http://freigeist.devmag.net/tricks/607-internet-connection-sharing-via-ad-hoc-network-for-iphone-and-ipad.html#comments</comments>
		<pubDate>Wed, 19 Oct 2011 05:59:08 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=607</guid>
		<description><![CDATA[As I have to be in hospital for a few days in Germany, I bought myself a SIM card and a month mobile internet flatrate. I have a netbook, a EEPC 1000go with an integrated mobile broadband card. However, in hospital I rather wanted to use my iPad and my iPhone to read papers and [...]]]></description>
			<content:encoded><![CDATA[<p>As I have to be in hospital for a few days in Germany, I bought myself a SIM card and a month mobile internet flatrate. I have a netbook, a EEPC 1000go with an integrated mobile broadband card.</p>
<p>However, in hospital I rather wanted to use my iPad and my iPhone to read papers and so on. As both are from the UK and I have not unlocked them, I wanted to indirectly use the internet on these devices through my netbook. I was amazed by how quick and easy it was setting things up&#8230;.</p>
<p><span id="more-607"></span></p>
<p><strong>Step 1: Setting up an ad-hoc network</strong></p>
<ol>
<li>From the Windows XP desktop, click <strong>Start</strong>, click <strong>Control Panel</strong>, click <strong>Network and Internet Connections</strong>, and then click <strong>Network Connections</strong>.</li>
<li>Right-click the wireless network connection, and then click <strong>Properties</strong>.</li>
<li>Click the <strong>Wireless Networks</strong> tab. In the wireless network adapter properties dialog box, click <strong>Add</strong> under <strong>Preferred networks</strong>.</li>
<li>On the <strong>Association</strong> tab, type the name of your ad hoc wireless network in <strong>Network name (SSID)</strong>. I named my network &#8220;<strong>questad</strong>&#8220;</li>
<li>Select the <strong>This is a computer-to-computer (ad hoc) network</strong> check box and clear the <strong>The key is provided for me automatically</strong> check box.</li>
<li>In <strong>Network Authentication</strong>, select <strong>Open</strong>.</li>
<li>In <strong>Data encryption</strong>, select <strong>WEP</strong>.</li>
<li>In <strong>Network key</strong>, type the WEP key. The WEP key should be a random sequence of hexadecimal digits or numbers, letters, and punctuation.</li>
</ol>
<p>10.In <strong>Confirm network key</strong>, retype the WEP key.</p>
<p>11.Click <strong>OK</strong> to save changes to the wireless network.</p>
<p>12.Click <strong>OK</strong> to save changes to the wireless network adapter.</p>
<p>&nbsp;</p>
<p><strong>Step 2: Enable Internet Connection Sharing</strong></p>
<p>1.From the Windows XP desktop, click <strong>Start</strong>, click <strong>Control Panel</strong>, click <strong>Network and Internet Connections</strong>, and then click <strong>Network Connections</strong>.</p>
<p>2.Right-click the Mobile internet dialup connection that is used to access the Internet, and then click <strong>Properties</strong>.</p>
<p>3.On the <strong>Advanced </strong>tab, select the <strong>Allow other network users to connect through this computer&#8217;s Internet connection</strong> check box and clear the <strong>Allow other network users to control or disable this shared Internet connection</strong> check box.</p>
<p>&nbsp;</p>
<p><strong>Step 3: Connecting the iPhone or iPad to the ad-hoc network</strong></p>
<p>Note that you need to reconnect the mobile internet, as changes will only applyto a newly established connection. Turning on wirless network on the iPhone, you should see the network you created. You can now simply connect to it and you are good to go.</p>
<p>&nbsp;
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/tricks/607-internet-connection-sharing-via-ad-hoc-network-for-iphone-and-ipad.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/tricks/607-internet-connection-sharing-via-ad-hoc-network-for-iphone-and-ipad.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microfinance Map of India &#8211; another go&#8230;</title>
		<link>http://freigeist.devmag.net/economics/602-microfinance-map-of-india-another-go.html</link>
		<comments>http://freigeist.devmag.net/economics/602-microfinance-map-of-india-another-go.html#comments</comments>
		<pubDate>Fri, 30 Sep 2011 12:33:49 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Economics]]></category>
		<category><![CDATA[Microfinance]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=602</guid>
		<description><![CDATA[I gave it another go, trying to get a map that looks a bit nicer. This time, I tried to compute something like a density or intensity in a certain area. On the previous map, this was not visible very well. I used ggplot2 and a bit of R code, together with RGoogleMaps to produce the [...]]]></description>
			<content:encoded><![CDATA[<p>I gave it another go, trying to get a map that looks a bit nicer. This time, I tried to compute something like a density or intensity in a certain area. On the <a title="Microfinance in India: Getting a sense of the geographic distribution" href="http://freigeist.devmag.net/economics/597-microfinance-in-india-getting-a-sense-of-the-geological-distribution.html">previous map</a>, this was not visible very well. I used ggplot2 and a bit of R code, together with RGoogleMaps to produce the following picture:</p>
<div id="attachment_603" class="wp-caption alignnone" style="width: 490px"><a href="http://freigeist.devmag.net/wp-content/india-institution.png"><img class="size-full wp-image-603" title="Heatmap of Indian Microfinance Institutions and their Location" src="http://freigeist.devmag.net/wp-content/india-institution.png" alt="" width="480" height="480" /></a><p class="wp-caption-text">This map displays the intensity of microfinance institution headquarter distribution across India. The data comes from the MIX Market.</p></div>
<p>&nbsp;</p>
<p>The fact that many MFIs are clustered around in the south is highlighted quite strongly. What this graph does not take into account however, is their variable size. This is problematic and I agree that this needs further refinement, i.e. that the intensity takes into account how big an MFI is. However, I would conjecture that this merely makes the contrasts in such a map just stronger.</p>
<p>&nbsp;
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/economics/602-microfinance-map-of-india-another-go.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/economics/602-microfinance-map-of-india-another-go.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microfinance in India: Getting a sense of the geographic distribution</title>
		<link>http://freigeist.devmag.net/economics/597-microfinance-in-india-getting-a-sense-of-the-geological-distribution.html</link>
		<comments>http://freigeist.devmag.net/economics/597-microfinance-in-india-getting-a-sense-of-the-geological-distribution.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 18:14:26 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Economics]]></category>
		<category><![CDATA[Microfinance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=597</guid>
		<description><![CDATA[I am working on a review paper on microfinance in India and use data from the MIX market. Today, I was amazed by how quick I conjured a map of India with the headquarters of the microfinance institutions that report data to the MIX market depicted on that map. Ideally, I would have more geolocation [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a review paper on microfinance in India and use data from the MIX market. Today, I was amazed by how quick I conjured a map of India with the headquarters of the microfinance institutions that report data to the MIX market depicted on that map. Ideally, I would have more geolocation data &#8211; but this is hard to come by. But what we can clearly see is the clustering of institutions in big cities and in the south, which was hit hardest by the recent crisis.</p>
<div id="attachment_598" class="wp-caption alignnone" style="width: 680px"><a href="http://freigeist.devmag.net/wp-content/map_india_mfis.png"><img class="size-full wp-image-598" title="Microfinance Institutions across India" src="http://freigeist.devmag.net/wp-content/map_india_mfis.png" alt="" width="670" height="691" /></a><p class="wp-caption-text">Microfinance Institutions across India</p></div>
<p>&nbsp;</p>
<p>I dont think anybody has produced such a map before. In fact, I can do this for all institutions reporting data around the world, which may be interesting to see. Also, I already tried to make the size of the dot proportional to e.g. measures of real yield or color-coding the nearest neighborhood (say the neigbhouring districts) by the average loan sizes reported. Lots of things to do. Maybe thats something for the guys at MIX Market or for <a href="http://blogs.cgdev.org/open_book/2011/03/interest-rates-by-region.php">David Roodman</a> who, I think has finished his open book.</p>
<p>The key difficulty was actually not in plotting the map (though it took some time), but in obtaining geo-data on where the headquarters of the microfinance institutions are located. I managed to obtain this data &#8211; though its not perfect &#8211; by making calls to the Google MAP API via a PHP script., basically using the following two functions:</p>
<p><span id="more-597"></span></p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> ResponseToArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> findLocation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://maps.google.com/maps/geo?q=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$string</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;output=json&amp;sensor=true_or_false&amp;key=your_api_key&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$raw</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$geodata</span> <span style="color: #339933;">=</span> ResponseToArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$point</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$geodata</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Placemark&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Point&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;coordinates&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$point</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div></div>

<p>The first one transforms the JSON return into an array and the latter, actually does the call. The variable $string should contain the actual paramters, such as the city and the zip code of where the institution is located.</p>
<p>&nbsp;
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/economics/597-microfinance-in-india-getting-a-sense-of-the-geological-distribution.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/economics/597-microfinance-in-india-getting-a-sense-of-the-geological-distribution.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Animation from Kiva data</title>
		<link>http://freigeist.devmag.net/economics/595-animation-from-kiva-data.html</link>
		<comments>http://freigeist.devmag.net/economics/595-animation-from-kiva-data.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 10:50:00 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Economics]]></category>
		<category><![CDATA[Microfinance]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=595</guid>
		<description><![CDATA[I just came accross this amazing animation, which depicts lending flows from Kiva lenders to Kiva borrowers in the field. I have been working on a few pieces of research with my colleague Jon de Quidt using Kiva data. However, that work has stalled a bit as prioritization moved it towards the end of the [...]]]></description>
			<content:encoded><![CDATA[<p>I just came accross this amazing animation, which depicts lending flows from Kiva lenders to Kiva borrowers in the field. I have been working on a few pieces of research with my colleague Jon de Quidt using Kiva data. However, that work has stalled a bit as prioritization moved it towards the end of the queue. However, this animization is indeed inspiring and it is somewhat awaking the urge in me, not to wait too long to continue work on Kiva.</p>
<p>&nbsp;<br />
<iframe src="http://player.vimeo.com/video/28413747?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0"></iframe>
<p><a href="http://vimeo.com/28413747">Intercontinental Ballistic Microfinance</a> from <a href="http://vimeo.com/user5173862">Kiva Microfunds</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>On another note, I am going to try to do some more work with R on mapping data, trying out several packages:</p>
<ul>
<li><a href="http://crantastic.org/packages/RgoogleMaps">http://crantastic.org/packages/RgoogleMaps</a></li>
<li><a href="http://cran.r-project.org/web/packages/maps/index.html">http://cran.r-project.org/web/packages/maps/index.html</a></li>
<li><a href="http://crantastic.org/packages/RgoogleMaps">http://crantastic.org/packages/RgoogleMaps</a></li>
</ul>
<p>I found working with ArcGIS way too clumsy&#8230;</p>
<p>&nbsp;
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/economics/595-animation-from-kiva-data.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/economics/595-animation-from-kiva-data.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How co-workers see each other&#8230;</title>
		<link>http://freigeist.devmag.net/random-impressions/586-how-co-workers-see-each-other.html</link>
		<comments>http://freigeist.devmag.net/random-impressions/586-how-co-workers-see-each-other.html#comments</comments>
		<pubDate>Thu, 01 Sep 2011 10:02:01 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Random Impressions]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=586</guid>
		<description><![CDATA[I thought this was a bit provoking and quite funny&#8230;where would you place yourself on that? &#160; As seen on http://i.imgur.com/vRTRP.jpg]]></description>
			<content:encoded><![CDATA[<p>I thought this was a bit provoking and quite funny&#8230;where would you place yourself on that?</p>
<p>&nbsp;</p>
<p><img src="http://i.imgur.com/vRTRP.jpg" alt="" width="480" height="383" /></p>
<p>As seen on http://i.imgur.com/vRTRP.jpg
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/random-impressions/586-how-co-workers-see-each-other.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/random-impressions/586-how-co-workers-see-each-other.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R Function Binding Vectors and Matrices of Variable Length, bug fixed</title>
		<link>http://freigeist.devmag.net/r/576-r-function-binding-vectors-and-matrices-of-variable-length.html</link>
		<comments>http://freigeist.devmag.net/r/576-r-function-binding-vectors-and-matrices-of-variable-length.html#comments</comments>
		<pubDate>Fri, 19 Aug 2011 07:04:40 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[Progra]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=576</guid>
		<description><![CDATA[Now this is something very geeky, but useful. I had to bind two matrices or vectors together to become a bigger matrix. However, they need not have the same number of rows or even the same row names. The standard cbind() functions require the vectors or matrices to be compatible. The matching is &#8220;stupid&#8221;, in [...]]]></description>
			<content:encoded><![CDATA[<p>Now this is something very geeky, but useful. I had to bind two matrices or vectors together to become a bigger matrix. However, they need not have the same number of rows or even the same row names.</p>
<p>The standard cbind() functions require the vectors or matrices to be compatible. The matching is &#8220;stupid&#8221;, in the sense that it ignores any order or assumes that the elements which are to be joined into a matrix have the same row names. This, of course, need not be the case. A classical merge command would fail here, as we dont really know what to merge by and what to merge on.</p>
<p>Ok&#8230; I am not being clear here. Suppose you want to merge two vectors</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">A 2
B 4
C 3</pre></td></tr></table></div></div>

<p>and</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">G 2
B 1
C 3
E 1</pre></td></tr></table></div></div>

<p>now the resulting matrix should be</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">A  2  NA
B  4  1
C  3  3
E NA  1
G NA  2</pre></td></tr></table></div></div>

<p>Now the following Rfunction allows you to do this. It is important however, that you assign rownames to the objects to be merged (the A,B,C,E,G in the example), as it does matching on these.</p>
<pre>cbindM &lt;-
function(A, v, repl=NA) {

  dif &lt;- setdiff(union(rownames(A),rownames(v)),intersect(rownames(A),rownames(v)))
#if names is the same, then a simple cbind will do
    if(length(dif)==0) {

      A&lt;- cbind(A,v[match(rownames(A),rownames(v))])

        rownames(A) &lt;- rownames(v)

    }    else if(length(dif)&gt;0) {#sets are not equal, so either matrix is longer / shorter

#this tells us which elements in dif are part of A (and of v) respectively
      for(i in dif)     {

        if(is.element(i,rownames(A))) {
#element is in A but not in v, so add it to v and then a        

          temp&lt;-matrix(data =repl, nrow = 1, ncol = ncol(v), byrow = FALSE, dimnames =list(i))
            v &lt;- rbind(v,temp)

        } else {
# element is in v but not in A, so add it to A

          temp&lt;-matrix(data = repl, nrow = 1, ncol = ncol(A), byrow = FALSE, dimnames =list(i))
            A&lt;-rbind(A,temp)
        }
      }

      A&lt;-cbind(A,v[match(rownames(A),rownames(v))])

    }

  A
}</pre>
<p>Note: 09.11.2011: I fixed a bug and added a bit more functionality. You can now tell it, with what you want the missing data to be replaced. Its standard to replace it with NA but you could change it to anything you want.</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">&nbsp;</pre></td></tr></table></div></div>

<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/r/576-r-function-binding-vectors-and-matrices-of-variable-length.html" /></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/r/576-r-function-binding-vectors-and-matrices-of-variable-length.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>London Riots : Catch the Looters!</title>
		<link>http://freigeist.devmag.net/london/573-london-riots-catch-the-looters.html</link>
		<comments>http://freigeist.devmag.net/london/573-london-riots-catch-the-looters.html#comments</comments>
		<pubDate>Tue, 09 Aug 2011 16:23:58 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[London]]></category>
		<category><![CDATA[Random Impressions]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/?p=573</guid>
		<description><![CDATA[Today we were told to leave office early: Hi All Due to anticipated rioting in the Tottenham Court Road area this evening, businesses in the area are being advised to close at 5pm. So I would recommend that we go along with this as well and try to finish up as close to 5pm as [...]]]></description>
			<content:encoded><![CDATA[<p>Today we were told to leave office early:</p>
<blockquote><p>Hi All</p>
<div>Due to anticipated rioting in the Tottenham Court Road area this evening, businesses in the area are being advised to close at 5pm. So I would recommend that we go along with this as well and try to finish up as close to 5pm as possible. Last access to and from this building today will be at 7pm.</div>
</blockquote>
<div>So far, its still quiet.  In the meantime, Catch the Looters!</div>
<div><img src="http://24.media.tumblr.com/tumblr_lpnxr96mxp1r1pwklo1_500.jpg" alt="" /></div>
<div><a href="http://catchalooter.tumblr.com/post/8688645379" target="_blank">http://catchalooter.tumblr.<wbr>com/post/8688645379</wbr></a></div>
<div><img src="http://i.imgur.com/KVvgW.jpg" alt="" /></div>
<div><a href="http://imgur.com/KVvgW" target="_blank">http://imgur.com/KVvgW</a></div>
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/london/573-london-riots-catch-the-looters.html" /></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/london/573-london-riots-catch-the-looters.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back in London &#8211; really!</title>
		<link>http://freigeist.devmag.net/london/569-back-in-london-really.html</link>
		<comments>http://freigeist.devmag.net/london/569-back-in-london-really.html#comments</comments>
		<pubDate>Tue, 05 Jul 2011 21:57:10 +0000</pubDate>
		<dc:creator>Thiemo Fetzer</dc:creator>
				<category><![CDATA[Economics]]></category>
		<category><![CDATA[London]]></category>
		<category><![CDATA[PhD]]></category>

		<guid isPermaLink="false">http://freigeist.devmag.net/london/back-in-london-really/</guid>
		<description><![CDATA[I just returned to London after 3 1/2 weeks in London. And what a return it was. I finally passed all the exams needed and I can now focus fully on my Phd. That was about the good news! Of course, London greeted me with a Sunny morning but it would end up hitting me [...]]]></description>
			<content:encoded><![CDATA[<p>I just returned to London after 3 1/2 weeks in London. And what a return it was. I finally passed all the exams needed and I can now focus fully on my Phd. That was about the good news!</p>
<p>Of course, London greeted me with a Sunny morning but it would end up hitting me hard with rain later that day. And that was after bad news from our advisors and supervisors that our work ok Kiva is most likely in vain as we would never really get it published in a really good journal.</p>
<p>So we will see, the other projects are still up and running, but I need to get an idea for a joan Market paper sometime soon. I am down for 2013/2014 as the prospective year. Just two more years to go, exciting but a bit scary as well.
<div class="fbconnect_share" style="">
<div id="fbsharefooter"><fb:share-button class="url" type="button_count" href="http://freigeist.devmag.net/london/569-back-in-london-really.html" /></div>
</div>
</p>]]></content:encoded>
			<wfw:commentRss>http://freigeist.devmag.net/london/569-back-in-london-really.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

