{"id":2905,"date":"2023-07-20T04:10:12","date_gmt":"2023-07-20T04:10:12","guid":{"rendered":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/"},"modified":"2023-07-20T04:10:12","modified_gmt":"2023-07-20T04:10:12","slug":"leggere-il-file-zip-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/","title":{"rendered":"Come leggere i file zip in r (con esempio)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi di base per leggere un file ZIP in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">library<\/span> (readr)\n\n<span style=\"color: #008080;\">#import data1.csv located within my_data.zip<\/span>\ndf &lt;- read_csv(unzip(\" <span style=\"color: #ff0000;\">my_data.zip<\/span> \", \" <span style=\"color: #ff0000;\">data1.csv<\/span> \"))\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come utilizzare questa sintassi nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio: come leggere i file Zip in R<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Diciamo che ho un file ZIP chiamato <strong>my_data.zip<\/strong> che contiene i seguenti tre file CSV:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">dati1.csv<\/span><\/li>\n<li> <span style=\"color: #000000;\">dati2.csv<\/span><\/li>\n<li> <span style=\"color: #000000;\">dati3.csv<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Supponendo che la mia <a href=\"https:\/\/statorials.org\/it\/setwd-getwd-in-r\/\" target=\"_blank\" rel=\"noopener\">directory di lavoro<\/a> contenga questo file ZIP, posso utilizzare la seguente sintassi per visualizzare tutti i file che si trovano in <strong>my_data.zip<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display all files in my_data.zip<\/span>\nunzip(\" <span style=\"color: #ff0000;\">my_data.zip<\/span> \", list = <span style=\"color: #008000;\">TRUE<\/span> )\n\n       Name Length Date\n1 data1.csv 37 2022-03-10 09:48:00\n2 data2.csv 36 2022-03-10 09:49:00\n3 data3.csv 34 2022-03-10 10:54:00 \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere i nomi di ciascun file situato in <strong>my_data.zip<\/strong> insieme alla loro lunghezza e la data in cui sono stati creati.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Quindi posso utilizzare la seguente sintassi per importare il set di dati chiamato <strong>data1.csv<\/strong> in un frame di dati in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">library<\/span> (readr)\n\n<span style=\"color: #008080;\">#read data1.csv into data frame\n<\/span>df1 &lt;- read_csv(unzip(\" <span style=\"color: #ff0000;\">my_data.zip<\/span> \", \" <span style=\"color: #ff0000;\">data1.csv<\/span> \"))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df1\n\n# A tibble: 4 x 2\n  team points\n    \n1 to 12\n2 B 31\n3 C 27\n4 D 30\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere che R ha importato con successo questo file CSV in un frame di dati.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : puoi trovare la documentazione completa per la funzione <strong>read_csv()<\/strong> <a href=\"https:\/\/readr.tidyverse.org\/reference\/read_delim.html\" target=\"_blank\" rel=\"noopener\">qui<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come importare altri file in R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/importare-csv-in-r\/\" target=\"_blank\" rel=\"noopener\">Come importare file CSV in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/r-leggi-csv-da-lurl\/\" target=\"_blank\" rel=\"noopener\">Come importare un CSV da un URL in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/importare-excel-in-r\/\" target=\"_blank\" rel=\"noopener\">Come importare file Excel in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi di base per leggere un file ZIP in R: library (readr) #import data1.csv located within my_data.zip df &lt;- read_csv(unzip(&#8221; my_data.zip &#8220;, &#8221; data1.csv &#8220;)) L&#8217;esempio seguente mostra come utilizzare questa sintassi nella pratica. Esempio: come leggere i file Zip in R Diciamo che ho un file ZIP chiamato my_data.zip [&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 leggere i file zip in R (con esempio) - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.\" \/>\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\/leggere-il-file-zip-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come leggere i file zip in R (con esempio) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-20T04:10:12+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\/leggere-il-file-zip-in-r\/\",\"url\":\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/\",\"name\":\"Come leggere i file zip in R (con esempio) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-20T04:10:12+00:00\",\"dateModified\":\"2023-07-20T04:10:12+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come leggere i file zip in r (con esempio)\"}]},{\"@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 leggere i file zip in R (con esempio) - Statorials","description":"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.","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\/leggere-il-file-zip-in-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come leggere i file zip in R (con esempio) - Statorials","og_description":"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.","og_url":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-20T04:10:12+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\/leggere-il-file-zip-in-r\/","url":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/","name":"Come leggere i file zip in R (con esempio) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-20T04:10:12+00:00","dateModified":"2023-07-20T04:10:12+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come leggere i file zip in R, incluso un esempio passo passo.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come leggere i file zip in r (con esempio)"}]},{"@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\/2905"}],"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=2905"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/2905\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=2905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=2905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=2905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}