{"id":1541,"date":"2008-05-01T16:57:15","date_gmt":"2008-05-01T14:57:15","guid":{"rendered":"http:\/\/www.wjst.de\/blog\/?page_id=1541"},"modified":"2008-05-01T16:57:15","modified_gmt":"2008-05-01T14:57:15","slug":"3-r-tips-for-loops","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2008\/05\/3-r-tips-for-loops\/","title":{"rendered":"3 R tips for loops"},"content":{"rendered":"<p>Tip 1: Avoid loops.<br \/>\nThey are generally slow &#8211; use a function instead. Even with the need of variable and fixed columns in a loop, a function may be constructed like<br \/>\napply(data,2,function(col2){table(col1,col2)<\/p>\n<p>Tip 2: Always show current state.<br \/>\nInclude options(warn=1) and show current state with cat(&#8220;message\\n&#8221;);flush.console();<\/p>\n<p>Tip 3: Avoid merging steps.<br \/>\nUse instead datasets in same order and with the same subset of the larger table before updating anew column with data from the second table.<\/p>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 09.06.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>Tip 1: Avoid loops. They are generally slow &#8211; use a function instead. Even with the need of variable and fixed columns in a loop, a function may be constructed like apply(data,2,function(col2){table(col1,col2) Tip 2: Always show current state. Include options(warn=1) and show current state with cat(&#8220;message\\n&#8221;);flush.console(); Tip 3: Avoid merging steps. Use instead datasets in &hellip; <a href=\"https:\/\/www.wjst.de\/blog\/sciencesurf\/2008\/05\/3-r-tips-for-loops\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">3 R tips for loops<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1541","post","type-post","status-publish","format-standard","hentry","category-asthma-allergy"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/1541","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=1541"}],"version-history":[{"count":0,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/1541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}