{"id":9479,"date":"2018-02-08T18:19:53","date_gmt":"2018-02-08T17:19:53","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?p=9479"},"modified":"2019-08-20T18:20:24","modified_gmt":"2019-08-20T18:20:24","slug":"whatever-can-go-wrong-will-go-wrong-r-join","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2018\/02\/whatever-can-go-wrong-will-go-wrong-r-join\/","title":{"rendered":"whatever can go wrong, will go wrong: R join"},"content":{"rendered":"<p><a href=\"https:\/\/mathgen.stats.ox.ac.uk\/genetics_software\/snptest\/snptest.html\">SNPtest<\/a> requires<\/p>\n<blockquote><p>the sample files for each cohort have exactly the same set of covariates and phenotypes and these occur in the same order in the files<\/p><\/blockquote>\n<p>Sounds clear.<!--more--><br \/>\nBut when merging phenotypes in R using the &#8220;merge&#8221; function, the original order of ids in the first file was destroyed without notice. And SNPtest will accept a wrong order without any error message (a clear design error of SNPtest). The workaround is quite simple: Never use &#8220;merge&#8221; but &#8220;join&#8221; in R<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nlibrary(plyr)\r\ndf_total &lt;- join(df_1, df_2, type=&quot;left&quot;)\r\n<\/pre>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 09.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>SNPtest requires the sample files for each cohort have exactly the same set of covariates and phenotypes and these occur in the same order in the files Sounds clear. &nbsp; CC-BY-NC Science Surf , accessed 09.04.2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,9],"tags":[],"class_list":["post-9479","post","type-post","status-publish","format-standard","hentry","category-genetics-biology","category-computer-software"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/9479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=9479"}],"version-history":[{"count":4,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/9479\/revisions"}],"predecessor-version":[{"id":13280,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/9479\/revisions\/13280"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=9479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=9479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=9479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}