{"id":1720,"date":"2009-09-21T17:53:11","date_gmt":"2009-09-21T16:53:11","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=1720"},"modified":"2009-12-20T11:08:26","modified_gmt":"2009-12-20T10:08:26","slug":"matlab-and-r-rosetta-stone","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=1720","title":{"rendered":"MATLAB and R &#8216;Rosetta Stone&#8217;"},"content":{"rendered":"<p>I was recently given the task of converting a small piece of code written in <a href=\"http:\/\/www.r-project.org\/\">R<\/a>, the free open-source programming language heavily used by statisticians, into <a href=\"http:\/\/www.mathworks.co.uk\/\">MATLAB<\/a> which was an interesting exercise since I had never coded a single line of R in my life!\u00a0 Fortunately for me, the code was rather simple and I didn&#8217;t have too much trouble with it but other people may not be so lucky since both MATLAB and R can be rather complicated to say the least.\u00a0 Wouldn&#8217;t it be nice if there was a sort of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Rosetta_Stone\">Rosetta Stone<\/a> that helped you to translate between the two systems?<\/p>\n<p>Happily, it turns out that there is in the form of <a href=\"http:\/\/www.math.umaine.edu\/~hiebeler\/comp\/matlabR.html\">The MATLAB \/ R Reference by David Hiebeler<\/a> which gives both the R and MATLAB commands for hundreds of common (and some not so common) operations.<\/p>\n<p>While flicking through the 47 page document I noted that there are a few MATLAB commands for which David hasn&#8217;t found an R equivalent (possibly because there simply isn&#8217;t one of course).\u00a0 For example, at number 161 of David&#8217;s document he describes the MATLAB command<\/p>\n<p><strong>yy=spline(x,y,xx) <\/strong><\/p>\n<p>which he describes as<\/p>\n<p><em>&#8216;Fit cubic spline with \u201cnot-a-knot\u201d conditions (the first two piecewise cubics coincide,as do the last two), to points (xi , yi ) whose coordinates are in vectors x and y; evaluate at points whose x coordinates are in vector xx, storing corresponding y\u2019s in yy.&#8217;<\/em><\/p>\n<p>At the moment David doesn&#8217;t know of an R equivalent so if you are a R master then maybe you could help out with this extremely useful document?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently given the task of converting a small piece of code written in R, the free open-source programming language heavily used by statisticians, into MATLAB which was an interesting exercise since I had never coded a single line of R in my life!\u00a0 Fortunately for me, the code was rather simple and I [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11,32,36],"tags":[],"class_list":["post-1720","post","type-post","status-publish","format-standard","hentry","category-matlab","category-open-source","category-r"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-rK","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1720"}],"version-history":[{"count":7,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1720\/revisions"}],"predecessor-version":[{"id":2075,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/1720\/revisions\/2075"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}