{"id":3467,"date":"2023-07-17T08:25:01","date_gmt":"2023-07-17T08:25:01","guid":{"rendered":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/"},"modified":"2023-07-17T08:25:01","modified_gmt":"2023-07-17T08:25:01","slug":"r-onverwachte-fout-other-in-other","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/","title":{"rendered":"Hoe op te lossen in r: fout: onverwacht &#39;anders&#39;; bij \u201canders\u201d"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een veel voorkomende fout die u in R kunt tegenkomen is:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>Error: unexpected 'else' in \"else\"\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Deze fout treedt meestal op als u een <strong>else-<\/strong> instructie aan het begin van een nieuwe regel in R plaatst.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt uitgelegd hoe u deze fout in de praktijk kunt oplossen.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Hoe de fout te reproduceren<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we een if else-instructie proberen te gebruiken om een specifieke tekenreeks af te drukken op basis van de waarde van een variabele:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#define x\n<\/span>x &lt;- 5\n\n<span style=\"color: #008080;\">#use if else statement to print string\n<\/span><span style=\"color: #008000;\">if<\/span> (x &lt; 7) {\n  <span style=\"color: #008000;\">print<\/span> (\" <span style=\"color: #ff0000;\">x is less than 7<\/span> \")\n}\n<span style=\"color: #008000;\">else<\/span> {\n  <span style=\"color: #008000;\">print<\/span> (\" <span style=\"color: #ff0000;\">x is not less than 7<\/span> \")\n}\n\nError: unexpected 'else' in \"else\"\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We ontvangen een foutmelding omdat we de <strong>else-<\/strong> instructie aan het begin van een geheel nieuwe regel hebben geplaatst.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Hoe u de fout kunt oplossen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Om deze fout op te lossen, hoeven we alleen maar de <strong>else<\/strong> -instructie \u00e9\u00e9n regel naar boven te verplaatsen, zodat deze onmiddellijk na de eerste sluitende accolade verschijnt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#define x\n<\/span>x &lt;- 5\n\n<span style=\"color: #008080;\">#use if else statement to print string\n<\/span><span style=\"color: #008000;\">if<\/span> (x &lt; 7) {\n  <span style=\"color: #008000;\">print<\/span> (\" <span style=\"color: #ff0000;\">x is less than 7<\/span> \")\n} <span style=\"color: #008000;\">else<\/span> {\n  <span style=\"color: #008000;\">print<\/span> (\" <span style=\"color: #ff0000;\">x is not less than 7<\/span> \")\n}\n\n[1] \"x is less than 7\"\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze keer krijgen we geen foutmelding en geeft de if else-instructie de string &#8222;x is kleiner dan 7&#8220; weer, aangezien x veel kleiner is dan 7.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende fouten in R kunt oplossen:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/r-list-object-kan-niet-worden-geforceerd-om-double-te-typen\/\" target=\"_blank\" rel=\"noopener\">Oplossing: Object (Lijst) kan niet worden geforceerd om &#8218;dubbel&#8216; te typen<\/a><br \/> Oplossing in R: ongeldige sjabloonformule in ExtractVars<br \/> <a href=\"https:\/\/statorials.org\/nl\/r-vervanging-op-lengte-nul\/\" target=\"_blank\" rel=\"noopener\">Hoe te repareren in R: vervanging heeft een lengte van nul<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een veel voorkomende fout die u in R kunt tegenkomen is: Error: unexpected &#8218;else&#8216; in &#8222;else&#8220; Deze fout treedt meestal op als u een else- instructie aan het begin van een nieuwe regel in R plaatst. In deze tutorial wordt uitgelegd hoe u deze fout in de praktijk kunt oplossen. Hoe de fout te reproduceren [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3467","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-17T08:25:01+00:00\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/\",\"url\":\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/\",\"name\":\"Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-17T08:25:01+00:00\",\"dateModified\":\"2023-07-17T08:25:01+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe op te lossen in r: fout: onverwacht &#39;anders&#39;; bij \u201canders\u201d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials","description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.","og_url":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/","og_site_name":"Statorials","article_published_time":"2023-07-17T08:25:01+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/","url":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/","name":"Hoe op te lossen in R: Fout: onverwachte \u201celse\u201d in \u201celse\u201d - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-17T08:25:01+00:00","dateModified":"2023-07-17T08:25:01+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout: onverwachte &quot;else&quot; in &quot;else&quot;.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/r-onverwachte-fout-other-in-other\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe op te lossen in r: fout: onverwacht &#39;anders&#39;; bij \u201canders\u201d"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=3467"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3467\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}