{"id":1417,"date":"2023-07-26T11:38:51","date_gmt":"2023-07-26T11:38:51","guid":{"rendered":"https:\/\/statorials.org\/it\/percentuale-in-r\/"},"modified":"2023-07-26T11:38:51","modified_gmt":"2023-07-26T11:38:51","slug":"percentuale-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/percentuale-in-r\/","title":{"rendered":"Formatta i numeri come percentuali in r (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Il modo pi\u00f9 semplice per formattare i numeri come percentuali in R \u00e8 utilizzare la funzione <strong>percent()<\/strong> del pacchetto <a href=\"https:\/\/cran.r-project.org\/web\/packages\/scales\/scales.pdf\" target=\"_blank\" rel=\"noopener\">scales<\/a> . Questa funzione utilizza la seguente sintassi:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>percentuale(x, precisione = 1)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Oro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>x:<\/strong> l&#8217;oggetto da formattare in percentuale.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>precisione:<\/strong> un numero a cui arrotondare. Ad esempio, utilizzare 0,01 per arrotondare a due cifre decimali.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Questo tutorial fornisce diversi esempi di utilizzo pratico di questa funzione.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Esempio 1: formattare le percentuali in un vettore<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come formattare i numeri come percentuali in un vettore:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #993300;\">library<\/span> (scales)<\/span>\n\n#createdata<\/span>\ndata &lt;- c(.3, .7, .14, .18, .22, .78)\n\n<span style=\"color: #008080;\">#format numbers as percentages\n<\/span><span style=\"color: #3366ff;\">percent<\/span> (data, accuracy = <span style=\"color: #008000;\">1<\/span> )\n\n[1] \"30%\" \"70%\" \"14%\" \"18%\" \"22%\" \"78%\"\n\n<span style=\"color: #008080;\">#format numbers as percentages with one decimal place\n<\/span><span style=\"color: #3366ff;\">percent<\/span> (data, accuracy = <span style=\"color: #008000;\">0.1<\/span> )\n\n[1] \"30.0%\" \"70.0%\" \"14.0%\" \"18.0%\" \"22.0%\" \"78.0%\"\n\n<span style=\"color: #008080;\">#format numbers as percentages with two decimal places\n<\/span><span style=\"color: #3366ff;\">percent<\/span> (data, accuracy = <span style=\"color: #008000;\">0.01<\/span> )\n\n[1] \"30.00%\" \"70.00%\" \"14.00%\" \"18.00%\" \"22.00%\" \"78.00%\"\n<\/strong><\/pre>\n<h3> <strong><span style=\"color: #000000;\">Esempio 2: formattare le percentuali in una colonna di frame di dati<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come formattare i numeri come percentuali in una colonna di 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: #993300;\">library<\/span> (scales)<\/span>\n\n#create data frame\n<span style=\"color: #000000;\">df = data. <span style=\"color: #3366ff;\">frame<\/span> (region = c('A', 'B', 'C', 'D'),\n                growth = c(.3, .7, .14, .18))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n  region growth\n1 to 0.30\n2 B 0.70\n3 C 0.14\n4 D 0.18\n\n<span style=\"color: #008080;\">#format numbers as percentages in growth column\n<\/span>df$growth &lt;- <span style=\"color: #3366ff;\">percent<\/span> (df$growth, accuracy= <span style=\"color: #008000;\">1<\/span> )\n\n<span style=\"color: #008080;\">#view updated data frame\n<\/span>df\n\n  region growth\n1 to 30%\n2 B 70%\n3 C 14%\n4 D 18%<\/span><\/span><\/strong><\/pre>\n<h3> <strong><span style=\"color: #000000;\">Esempio 3: formattare le percentuali in pi\u00f9 colonne di frame di dati<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come formattare i numeri come percentuali in pi\u00f9 colonne di 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: #993300;\">library<\/span> (scales)<\/span>\n\n#create data frame\n<span style=\"color: #000000;\">df = data. <span style=\"color: #3366ff;\">frame<\/span> (region = c('A', 'B', 'C', 'D'),\n                growth = c(.3, .7, .14, .18),\n                trend = c(.04, .09, .22, .25))<\/span>\n\n#view data frame\n<span style=\"color: #000000;\">df\n  region growth trend\n1 A 0.30 0.04\n2 B 0.70 0.09\n3 C 0.14 0.22\n4 D 0.18 0.25<\/span>\n\n#format numbers as percentages in growth and trend columns\n<span style=\"color: #000000;\">df[2:3] &lt;- <span style=\"color: #3366ff;\">sapply<\/span> (df[2:3], <span style=\"color: #008000;\">function<\/span> (x) <span style=\"color: #3366ff;\">percent<\/span> (x, accuracy= <span style=\"color: #008000;\">1<\/span> ))\n<\/span>\n#view updated data frame\n<span style=\"color: #000000;\">df\n\n  region growth trend\n1 to 30% 4%\n2 B 70% 9%\n3 C 14% 22%\n4 D 18% 25%\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Puoi trovare altri tutorial su R in questa pagina .<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Il modo pi\u00f9 semplice per formattare i numeri come percentuali in R \u00e8 utilizzare la funzione percent() del pacchetto scales . Questa funzione utilizza la seguente sintassi: percentuale(x, precisione = 1) Oro: x: l&#8217;oggetto da formattare in percentuale. precisione: un numero a cui arrotondare. Ad esempio, utilizzare 0,01 per arrotondare a due cifre decimali. Questo [&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>Formatta i numeri come percentuali in R (con esempi)<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.\" \/>\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\/percentuale-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Formatta i numeri come percentuali in R (con esempi)\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/percentuale-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-26T11:38:51+00:00\" \/>\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\/percentuale-in-r\/\",\"url\":\"https:\/\/statorials.org\/it\/percentuale-in-r\/\",\"name\":\"Formatta i numeri come percentuali in R (con esempi)\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-26T11:38:51+00:00\",\"dateModified\":\"2023-07-26T11:38:51+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/percentuale-in-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/percentuale-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/percentuale-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Formatta i numeri come percentuali in r (con esempi)\"}]},{\"@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":"Formatta i numeri come percentuali in R (con esempi)","description":"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.","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\/percentuale-in-r\/","og_locale":"it_IT","og_type":"article","og_title":"Formatta i numeri come percentuali in R (con esempi)","og_description":"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/percentuale-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-26T11:38:51+00:00","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\/percentuale-in-r\/","url":"https:\/\/statorials.org\/it\/percentuale-in-r\/","name":"Formatta i numeri come percentuali in R (con esempi)","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-26T11:38:51+00:00","dateModified":"2023-07-26T11:38:51+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come formattare i numeri come percentuali in R, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/percentuale-in-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/percentuale-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/percentuale-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Formatta i numeri come percentuali in r (con esempi)"}]},{"@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\/1417"}],"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=1417"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1417\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}