{"id":3970,"date":"2023-07-14T11:04:38","date_gmt":"2023-07-14T11:04:38","guid":{"rendered":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/"},"modified":"2023-07-14T11:04:38","modified_gmt":"2023-07-14T11:04:38","slug":"r-avviso-stat_bin-utilizzando-bin-30","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/","title":{"rendered":"Come gestire l&#39;avviso r: stat_bin() utilizzando bins = 30"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un avviso comune che potresti incontrare in R \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questo avviso viene visualizzato quando utilizzi <strong>geom_histogram()<\/strong> per creare un istogramma in ggplot2 e non sei in grado di specificare il numero di gruppi da utilizzare nell&#8217;istogramma.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Per evitare questo avviso, puoi utilizzare l&#8217;argomento <strong>bins<\/strong> per specificare il numero di bin da utilizzare:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>ggplot(df, aes(x=my_variable)) +\n  geom_histogram(bins= <span style=\"color: #008000;\">10<\/span> )<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">L&#8217;esempio seguente mostra come evitare questo avviso nella pratica.<\/span><\/span><\/p>\n<h2> <strong>Esempio: come evitare l&#8217;avviso stat_bins() utilizzando bins = 30<\/strong><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di utilizzare la funzione <strong>geom_histogram()<\/strong> di ggplot2 per creare un istogramma per una variabile in un frame di dati:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">library<\/span> (ggplot2)\n\n<span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seed<\/span> ( <span style=\"color: #008000;\">0<\/span> )\n\n<span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (my_values = rnorm( <span style=\"color: #008000;\">1000<\/span> ))\n\n<span style=\"color: #008080;\">#view head of data frame\n<\/span>head(df)\n\n   my_values\n1 1.2629543\n2 -0.3262334\n3 1.3297993\n4 1.2724293\n5 0.4146414\n6 -1.5399500\n\n<span style=\"color: #008080;\">#create histogram\n<\/span>ggplot(df, aes(x=my_values)) +\n  geom_histogram(col=' <span style=\"color: #ff0000;\">black<\/span> ', fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ')\n\n`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31818 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/hist30.jpg\" alt=\"\" width=\"487\" height=\"488\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che riceviamo l&#8217; <strong>avviso `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &#8220;binwidth&#8221;.<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Va notato che questo \u00e8 solo un avviso e l&#8217;istogramma \u00e8 comunque creato da ggplot2.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tuttavia, possiamo evitare completamente questo avviso utilizzando l&#8217;argomento <strong>bins<\/strong> in <strong>geom_histogram()<\/strong> per specificare il numero di bin da utilizzare nell&#8217;istogramma.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, possiamo utilizzare il codice seguente per utilizzare <strong>10<\/strong> contenitori per l&#8217;istogramma:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create histogram with 10 bins\n<\/span>ggplot(df, aes(x=my_values)) +\n  geom_histogram(col=' <span style=\"color: #ff0000;\">black<\/span> ', fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ', bins= <span style=\"color: #008000;\">10<\/span> )<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31819 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/hist30_1.jpg\" alt=\"\" width=\"444\" height=\"442\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che questa volta non riceviamo alcun messaggio di avviso e l&#8217;istogramma contiene esattamente 10 contenitori.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che meno contenitori utilizzi, pi\u00f9 ampio sar\u00e0 ciascun contenitore.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, potremmo invece utilizzare <strong>5<\/strong> contenitori:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create histogram with 5 bins\n<\/span>ggplot(df, aes(x=my_values)) +\n  geom_histogram(col=' <span style=\"color: #ff0000;\">black<\/span> ', fill=' <span style=\"color: #ff0000;\">steelblue<\/span> ', bins= <span style=\"color: #008000;\">5<\/span> )<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31820 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/hist30_2.jpg\" alt=\"\" width=\"486\" height=\"487\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che in questo istogramma sono presenti meno gruppi ma pi\u00f9 grandi.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Sentiti libero di utilizzare tutti i contenitori che desideri nel tuo istogramma.<\/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\/lerrore-rbind-nei-nomi-r-non-corrisponde-ai-nomi-precedenti\/\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema in R: i nomi non corrispondono ai nomi precedenti<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/nas-introdotto-con-la-coercizione-in-r\/\">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\/contrasti-applicati-a-fattori-con-2-o-piu-livelli\/\" target=\"_blank\" rel=\"noopener\">Come risolvere in R: i contrasti possono essere applicati solo a fattori con 2 o pi\u00f9 livelli<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un avviso comune che potresti incontrare in R \u00e8: `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. Questo avviso viene visualizzato quando utilizzi geom_histogram() per creare un istogramma in ggplot2 e non sei in grado di specificare il numero di gruppi da utilizzare nell&#8217;istogramma. Per evitare questo avviso, puoi utilizzare l&#8217;argomento bins 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 gestire l&#039;avviso R: stat_bin() utilizzando bins = 30 - Stology<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&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\/it\/r-avviso-stat_bin-utilizzando-bin-30\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come gestire l&#039;avviso R: stat_bin() utilizzando bins = 30 - Stology\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&quot;.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-14T11:04:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/hist30.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=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/\",\"url\":\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/\",\"name\":\"Come gestire l&#39;avviso R: stat_bin() utilizzando bins = 30 - Stology\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-14T11:04:38+00:00\",\"dateModified\":\"2023-07-14T11:04:38+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&quot;.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come gestire l&#39;avviso r: stat_bin() utilizzando bins = 30\"}]},{\"@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 gestire l&#39;avviso R: stat_bin() utilizzando bins = 30 - Stology","description":"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&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\/it\/r-avviso-stat_bin-utilizzando-bin-30\/","og_locale":"it_IT","og_type":"article","og_title":"Come gestire l&#39;avviso R: stat_bin() utilizzando bins = 30 - Stology","og_description":"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&quot;.","og_url":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/","og_site_name":"Statorials","article_published_time":"2023-07-14T11:04:38+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/hist30.jpg"}],"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\/r-avviso-stat_bin-utilizzando-bin-30\/","url":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/","name":"Come gestire l&#39;avviso R: stat_bin() utilizzando bins = 30 - Stology","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-14T11:04:38+00:00","dateModified":"2023-07-14T11:04:38+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come gestire il seguente avviso in R: `stat_bin()` utilizzando `bins = 30`. Scegli un valore migliore con &quot;binwidth&quot;.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/r-avviso-stat_bin-utilizzando-bin-30\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come gestire l&#39;avviso r: stat_bin() utilizzando bins = 30"}]},{"@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\/3970"}],"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=3970"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3970\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}