{"id":1809,"date":"2023-07-24T21:57:31","date_gmt":"2023-07-24T21:57:31","guid":{"rendered":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/"},"modified":"2023-07-24T21:57:31","modified_gmt":"2023-07-24T21:57:31","slug":"fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/","title":{"rendered":"Hoe op te lossen: fout in xy.coords(x, y, xlabel, ylabel, log): &#39;x&#39; en &#39;y&#39; lengtes verschillen"},"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;\"> <strong>Error in xy.coords(x, y, xlabel, ylabel, log): \n  'x' and 'y' lengths differ \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze fout treedt op wanneer u probeert een plot van twee variabelen te maken, maar de variabelen niet dezelfde lengte hebben.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In deze tutorial wordt precies uitgelegd hoe u deze fout kunt oplossen.<\/span><\/p>\n<h3> <strong>Hoe de fout te reproduceren<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we een spreidingsdiagram proberen te maken van de volgende twee variabelen in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define x and y variables<\/span>\nx &lt;- c(2, 5, 5, 8)\ny &lt;- c(22, 28, 32, 35, 40, 41)\n\n<span style=\"color: #008080;\">#attempt to create scatterplot of x vs. y<\/span>\nplot(x, y)\n\nError in xy.coords(x, y, xlabel, ylabel, log): \n  'x' and 'y' lengths differ\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We krijgen een foutmelding omdat de lengtes van x en y niet gelijk zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen dit bevestigen door de lengte van elke variabele af te drukken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#print length of x<\/span>\nlength(x)\n\n[1] 4\n\n<span style=\"color: #008080;\">#print length of y<\/span>\nlength(y)\n\n[1] 6\n\n<span style=\"color: #008080;\">#check if length of x and y are equal\n<\/span>length(x) <span style=\"color: #993300;\">==<\/span> length(y)\n\n[1] FALSE\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Hoe u de fout kunt oplossen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">De eenvoudigste manier om deze fout op te lossen, is door er eenvoudigweg voor te zorgen dat de twee vectoren dezelfde lengte hebben:<\/span><\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define x and y variables to have same length\n<\/span>x &lt;- c(2, 5, 5, 8, 9, 12)\ny &lt;- c(22, 28, 32, 35, 40, 41)\n\n<span style=\"color: #008080;\">#confirm that x and y are the same length<\/span>\nlength(x) <span style=\"color: #993300;\">==<\/span> length(y)\n\n[1] TRUE\n\n<span style=\"color: #008080;\">create scatterplot of x vs. y\n<\/span>plot(x, y)\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-17546 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/longueur1.png\" alt=\"\" width=\"454\" height=\"407\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Als de ene vector korter blijkt te zijn dan de andere, kun je ervoor kiezen om alleen waarden te plotten tot de lengte van de kortere vector.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Als vector xa bijvoorbeeld 4 waarden heeft en vector y 6 waarden heeft, kunnen we een spreidingsdiagram maken met alleen de eerste 4 waarden van elke vector:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define x and y variables<\/span>\nx &lt;- c(2, 5, 5, 8)\ny &lt;- c(22, 28, 32, 35, 40, 41)\n\n<span style=\"color: #008080;\">#create scatterplot of first 4 pairwise values of x vs. y<\/span>\nplot(x, y[1: <span style=\"color: #3366ff;\">length<\/span> (x)])\n<\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-17547 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/longueur2.png\" alt=\"\" width=\"455\" height=\"418\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Merk op dat alleen de eerste vier waarden van elke vector worden gebruikt om de puntenwolk te cre\u00ebren.<\/span><\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/nl\/nas-onder-dwang-geintroduceerd-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe op te lossen in R: NA&#8217;s ge\u00efntroduceerd door dwang<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/r-foutindex-buiten-bereik\/\" target=\"_blank\" rel=\"noopener\">Hoe te repareren in R: hint buiten de grenzen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\" target=\"_blank\" rel=\"noopener\">Oplossing: Een langere objectlengte is geen veelvoud van een kortere objectlengte<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een veel voorkomende fout die u in R kunt tegenkomen is: Error in xy.coords(x, y, xlabel, ylabel, log): &#8218;x&#8216; and &#8218;y&#8216; lengths differ Deze fout treedt op wanneer u probeert een plot van twee variabelen te maken, maar de variabelen niet dezelfde lengte hebben. In deze tutorial wordt precies uitgelegd hoe u deze fout kunt [&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-1809","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: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#039;x&#039; en &#039;y&#039; verschillen<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#039;x&#039; en &#039;y&#039; verschillen.\" \/>\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\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/\" \/>\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: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#039;x&#039; en &#039;y&#039; verschillen\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#039;x&#039; en &#039;y&#039; verschillen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T21:57:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/longueur1.png\" \/>\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=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/\",\"name\":\"Hoe op te lossen: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#39;x&#39; en &#39;y&#39; verschillen\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-24T21:57:31+00:00\",\"dateModified\":\"2023-07-24T21:57:31+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 in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#39;x&#39; en &#39;y&#39; verschillen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe op te lossen: fout in xy.coords(x, y, xlabel, ylabel, log): &#39;x&#39; en &#39;y&#39; lengtes verschillen\"}]},{\"@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: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#39;x&#39; en &#39;y&#39; verschillen","description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#39;x&#39; en &#39;y&#39; verschillen.","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\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe op te lossen: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#39;x&#39; en &#39;y&#39; verschillen","og_description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in R kunt oplossen: Fout in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#39;x&#39; en &#39;y&#39; verschillen.","og_url":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T21:57:31+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/longueur1.png"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/","url":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/","name":"Hoe op te lossen: fout in xy.coords (x, y, xlabel, ylabel, log): lengtes &#39;x&#39; en &#39;y&#39; verschillen","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-24T21:57:31+00:00","dateModified":"2023-07-24T21:57:31+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 in xy.coords(x, y, xlabel, ylabel, log): De lengtes &#39;x&#39; en &#39;y&#39; verschillen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/fout-in-xy-coordinaten-x-en-y-lengtes-verschillen-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe op te lossen: fout in xy.coords(x, y, xlabel, ylabel, log): &#39;x&#39; en &#39;y&#39; lengtes verschillen"}]},{"@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\/1809","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=1809"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/1809\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=1809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=1809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=1809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}