{"id":3280,"date":"2023-07-18T08:01:52","date_gmt":"2023-07-18T08:01:52","guid":{"rendered":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/"},"modified":"2023-07-18T08:01:52","modified_gmt":"2023-07-18T08:01:52","slug":"i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/","title":{"rendered":"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un errore che potresti riscontrare in R \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error: `data` must be a data frame, or other object coercible by `fortify()`,\n        not a digital vector\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questo errore si verifica quando tenti di utilizzare <strong>ggplot2<\/strong> per tracciare variabili in un frame di dati, ma fai riferimento a un vettore anzich\u00e9 a un frame di dati per l&#8217;argomento <strong>dati<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial spiega esattamente come correggere questo errore.<\/span><\/p>\n<h2> <strong>Come riprodurre l&#8217;errore<\/strong><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di avere il seguente frame di dati in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#create data frame\n<span style=\"color: #000000;\">df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (x=c(1, 2, 3, 4, 5, 6, 7, 8),\n                 y=c(4, 8, 14, 19, 14, 13, 9, 9))<\/span>\n\n#view data frame\n<span style=\"color: #000000;\">df\n\n  xy\n1 1 4\n2 2 8\n3 3 14\n4 4 19\n5 5 14\n6 6 13\n7 7 9\n8 8 9\n<\/span><\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Supponiamo ora di provare a creare un grafico a dispersione per visualizzare le variabili xey nel frame di dati:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #008080;\"><strong><span style=\"color: #000000;\"><span style=\"color: #008000;\">library<\/span> (ggplot2)<\/span>\n\n<span style=\"color: #000000;\"><span style=\"color: #008080;\">#attempt to create scatter plot\n<\/span>ggplot(df$x, aes(x=x, y=y)) +\n    geom_point()\n\nError: `data` must be a data frame, or other object coercible by `fortify()`,\n        not a digital vector\n<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Stiamo ricevendo un errore perch\u00e9 abbiamo fatto riferimento a un vettore numerico ( <strong>df$x<\/strong> ) nell&#8217;argomento <strong>dati<\/strong> della funzione <strong>ggplot()<\/strong> anzich\u00e9 a un frame di dati.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Come correggere l&#8217;errore<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il modo per correggere questo errore \u00e8 fare riferimento a un frame di dati per l&#8217;argomento <strong>data<\/strong> nella funzione <strong>ggplot()<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Nel nostro esempio, dovremmo usare <strong>df<\/strong> invece di <strong>df$x<\/strong> per l&#8217;argomento <strong>dati<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #008080;\"><strong><span style=\"color: #000000;\"><span style=\"color: #008000;\">library<\/span> (ggplot2)<\/span>\n\n<span style=\"color: #000000;\"><span style=\"color: #008080;\">#create scatterplot\n<\/span>ggplot(df, aes(x=x, y=y)) +\n    geom_point()\n<\/span><\/strong><\/span><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-27774 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ggerror2.jpg\" alt=\"\" width=\"482\" height=\"484\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che questa volta siamo in grado di creare la nuvola di punti con successo senza errori.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come risolvere altri errori comuni in R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/ggplot-non-sa-come-gestire-la-classe-dati-non-valida\/\">Come risolvere: ggplot2 non sa come gestire dati di classi non uguali<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/r-errore-metodo-di-stampa-non-valido-predefinito-stripchart\/\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema: Errore in stripchart.default(x1, \u2026): metodo di stampa non valido<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/errore-nelloggetto-evalpredvars-data-env-non-trovato\/\" target=\"_blank\" rel=\"noopener\">Come risolvere: errore in eval (predvars, data, env): oggetto &#8216;x&#8217; non trovato<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un errore che potresti riscontrare in R \u00e8: Error: `data` must be a data frame, or other object coercible by `fortify()`, not a digital vector Questo errore si verifica quando tenti di utilizzare ggplot2 per tracciare variabili in un frame di dati, ma fai riferimento a un vettore anzich\u00e9 a un frame di dati per [&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 correggere l&#039;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.\" \/>\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\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come correggere l&#039;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T08:01:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ggerror2.jpg\" \/>\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=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/\",\"url\":\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/\",\"name\":\"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-18T08:01:52+00:00\",\"dateModified\":\"2023-07-18T08:01:52+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico\"}]},{\"@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 correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials","description":"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.","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\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/","og_locale":"it_IT","og_type":"article","og_title":"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials","og_description":"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.","og_url":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/","og_site_name":"Statorials","article_published_time":"2023-07-18T08:01:52+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ggerror2.jpg"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/","url":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/","name":"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-18T08:01:52+00:00","dateModified":"2023-07-18T08:01:52+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come correggere il seguente errore in ggplot2: Errore: `data` deve essere un dataframe o un altro oggetto coercibile da `fortify()`, non un vettore numerico.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/i-dati-di-errore-ggplot2-devono-essere-un-frame-di-dati-o-un-oggetto-coercibile-da-fortificazione\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come correggere l&#39;errore: &quot;data&quot; deve essere un dataframe o un altro oggetto coercibile da &quot;fortify()&quot;, non un vettore numerico"}]},{"@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\/3280"}],"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=3280"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3280\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}