{"id":1809,"date":"2023-07-24T21:57:31","date_gmt":"2023-07-24T21:57:31","guid":{"rendered":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/"},"modified":"2023-07-24T21:57:31","modified_gmt":"2023-07-24T21:57:31","slug":"errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/","title":{"rendered":"Come risolvere: errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un errore comune che potresti riscontrare in R \u00e8:<\/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;\">Questo errore si verifica quando si tenta di creare un grafico di due variabili ma le variabili non hanno la stessa lunghezza.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega esattamente come correggere questo errore.<\/span><\/p>\n<h3> <strong>Come riprodurre l&#8217;errore<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo di provare a creare un grafico a dispersione delle seguenti due variabili 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;\">Riceviamo un errore perch\u00e9 le lunghezze di xey non sono uguali.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Possiamo confermarlo stampando la lunghezza di ciascuna variabile:<\/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>Come correggere l&#8217;errore<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Il modo pi\u00f9 semplice per correggere questo errore \u00e8 semplicemente assicurarsi che i due vettori abbiano la stessa lunghezza:<\/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=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Se un vettore risulta essere pi\u00f9 corto dell&#8217;altro, puoi scegliere di tracciare solo i valori fino alla lunghezza del vettore pi\u00f9 corto.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, se il vettore xa ha 4 valori e il vettore y ha 6 valori, potremmo creare un grafico a dispersione utilizzando solo i primi 4 valori di ciascun vettore:<\/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=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Si noti che solo i primi quattro valori di ciascun vettore vengono utilizzati per creare la nuvola di punti.<\/span><\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/nas-introdotto-con-la-coercizione-in-r\/\" target=\"_blank\" rel=\"noopener\">Come risolvere in R: NA introdotte dalla coercizione<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/\" target=\"_blank\" rel=\"noopener\">Come riparare in R: suggerimento fuori limite<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema: la lunghezza dell&#8217;oggetto maggiore non \u00e8 un multiplo della lunghezza dell&#8217;oggetto minore<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un errore comune che potresti riscontrare in R \u00e8: Error in xy.coords(x, y, xlabel, ylabel, log): &#8216;x&#8217; and &#8216;y&#8217; lengths differ Questo errore si verifica quando si tenta di creare un grafico di due variabili ma le variabili non hanno la stessa lunghezza. Questo tutorial spiega esattamente come correggere questo errore. Come riprodurre l&#8217;errore Supponiamo [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#039;x&#039; e &#039;y&#039; differiscono<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.\" \/>\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\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#039;x&#039; e &#039;y&#039; differiscono\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-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=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/\",\"url\":\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/\",\"name\":\"Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#39;x&#39; e &#39;y&#39; differiscono\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-24T21:57:31+00:00\",\"dateModified\":\"2023-07-24T21:57:31+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come risolvere: errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#39;x&#39; e &#39;y&#39; differiscono","description":"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.","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\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#39;x&#39; e &#39;y&#39; differiscono","og_description":"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.","og_url":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-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":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/","url":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/","name":"Come risolvere: errore in xy.coords (x, y, xlabel, ylabel, log): le lunghezze &#39;x&#39; e &#39;y&#39; differiscono","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-24T21:57:31+00:00","dateModified":"2023-07-24T21:57:31+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come correggere il seguente errore in R: Errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/errore-nelle-coordinate-xy-le-lunghezze-x-e-y-differiscono-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come risolvere: errore in xy.coords(x, y, xlabel, ylabel, log): le lunghezze &quot;x&quot; e &quot;y&quot; differiscono"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1809"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=1809"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1809\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}