{"id":4504,"date":"2023-07-10T14:25:59","date_gmt":"2023-07-10T14:25:59","guid":{"rendered":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/"},"modified":"2023-07-10T14:25:59","modified_gmt":"2023-07-10T14:25:59","slug":"r-elenca-i-file-per-data","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/","title":{"rendered":"Come elencare i file per data 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 elencare i file nella directory di lavoro corrente in R per data:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract all CSV files in working directory\n<\/span>file_info = file. <span style=\"color: #3366ff;\">info<\/span> ( <span style=\"color: #3366ff;\">list.files<\/span> (pattern=\" <span style=\"color: #ff0000;\">*.csv<\/span> \"))\n\n<span style=\"color: #008080;\">#sort files based on mtime (date and time modification)\n<\/span>file_info = file_info[ <span style=\"color: #008000;\">with<\/span> (file_info, <span style=\"color: #008000;\">order<\/span> (as. <span style=\"color: #3366ff;\">POSIXct<\/span> (mtime))), ]\n\n<span style=\"color: #008080;\">#view only file names with modification date and time\n<\/span>file_info[c(\" <span style=\"color: #ff0000;\">mtime<\/span> \")]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come utilizzare questa sintassi nella pratica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio: come elencare i file per data in R<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Supponiamo di voler elencare tutti i file CSV nella <a href=\"https:\/\/statorials.org\/it\/setwd-getwd-in-r\/\" target=\"_blank\" rel=\"noopener\">directory di lavoro corrente<\/a> in R per data.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Posso utilizzare la seguente sintassi per estrarre prima tutti i file CSV (con le informazioni sui file) dalla directory di lavoro corrente:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#extract all CSV files in working directory\n<\/span>file_info = file. <span style=\"color: #3366ff;\">info<\/span> ( <span style=\"color: #3366ff;\">list.files<\/span> (pattern=\" <span style=\"color: #ff0000;\">*.csv<\/span> \"))\n\n<span style=\"color: #008080;\">#view all CSV files<\/span>\nfile_info\n\n                        size isdir mode mtime ctime atime exe\nbasketball_data.csv 55 FALSE 666 2023-01-06 11:07:43 2022-07-12 09:07:26 2023-04-18 09:42:19 no\ndf1.csv 126 FALSE 666 2022-04-21 10:48:24 2022-04-21 10:48:24 2023-04-18 09:42:19 no\ndf2.csv 126 FALSE 666 2022-04-21 10:48:30 2022-04-21 10:48:29 2023-04-18 09:42:19 no\ndf3.csv 126 FALSE 666 2022-04-21 10:48:34 2022-04-21 10:48:34 2023-04-18 09:42:19 no\nmy_data.csv 53 FALSE 666 2022-09-09 09:02:21 2022-04-22 09:00:13 2023-04-18 09:42:19 no\nmy_list.csv 90 FALSE 666 2022-04-21 09:40:01 2022-04-21 09:39:59 2023-04-18 09:42:19 no\nmy_test.csv 146 FALSE 666 2022-04-21 09:42:25 2022-04-21 09:42:25 2023-04-18 09:42:19 no\nplayer_stats.csv 137 FALSE 666 2023-04-11 09:07:20 2023-04-11 09:07:20 2023-04-18 09:42:19 no\nplayers_data.csv 50 FALSE 666 2023-01-06 09:44:12 2023-01-06 09:44:12 2023-04-18 09:42:19 no\nteam_info.csv 131 FALSE 666 2023-04-11 09:07:21 2023-04-11 09:07:21 2023-04-18 09:42:19 no\ntest.csv 18059168 FALSE 666 2022-09-07 09:07:34 2020-02-01 13:44:03 2023-04-18 09:42:19 no\nuneven_data.csv 43 FALSE 666 2023-01-06 14:02:17 2023-01-06 14:00:27 2023-04-18 09:42:19 no\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Posso quindi utilizzare la funzione <strong>order()<\/strong> per ordinare i file in base a <strong>mtime<\/strong> , che rappresenta la data e l&#8217;ora dell&#8217;ultima modifica dei file:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#sort files based on mtime (date and time modification)\n<\/span>file_info = file_info[ <span style=\"color: #008000;\">with<\/span> (file_info, <span style=\"color: #008000;\">order<\/span> (as. <span style=\"color: #3366ff;\">POSIXct<\/span> (mtime))), ]\n\n<span style=\"color: #008080;\">#view sorted files<\/span>\nfile_info\n\n                        size isdir mode mtime ctime atime exe\nmy_list.csv 90 FALSE 666 2022-04-21 09:40:01 2022-04-21 09:39:59 2023-04-18 09:42:19 no\nmy_test.csv 146 FALSE 666 2022-04-21 09:42:25 2022-04-21 09:42:25 2023-04-18 09:42:19 no\ndf1.csv 126 FALSE 666 2022-04-21 10:48:24 2022-04-21 10:48:24 2023-04-18 09:42:19 no\ndf2.csv 126 FALSE 666 2022-04-21 10:48:30 2022-04-21 10:48:29 2023-04-18 09:42:19 no\ndf3.csv 126 FALSE 666 2022-04-21 10:48:34 2022-04-21 10:48:34 2023-04-18 09:42:19 no\ntest.csv 18059168 FALSE 666 2022-09-07 09:07:34 2020-02-01 13:44:03 2023-04-18 09:42:19 no\nmy_data.csv 53 FALSE 666 2022-09-09 09:02:21 2022-04-22 09:00:13 2023-04-18 09:42:19 no\nplayers_data.csv 50 FALSE 666 2023-01-06 09:44:12 2023-01-06 09:44:12 2023-04-18 09:42:19 no\nbasketball_data.csv 55 FALSE 666 2023-01-06 11:07:43 2022-07-12 09:07:26 2023-04-18 09:42:19 no\nuneven_data.csv 43 FALSE 666 2023-01-06 14:02:17 2023-01-06 14:00:27 2023-04-18 09:42:19 no\nplayer_stats.csv 137 FALSE 666 2023-04-11 09:07:20 2023-04-11 09:07:20 2023-04-18 09:42:19 no\nteam_info.csv 131 FALSE 666 2023-04-11 09:07:21 2023-04-11 09:07:21 2023-04-18 09:42:19 no\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che puoi invece utilizzare <strong>ctime<\/strong> se desideri ordinare i file in base <em>alla data di creazione<\/em> o <strong>atime<\/strong> per ordinare i file in base alla <em>data di accesso<\/em> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Infine, possiamo sottoimpostare il frame di dati per visualizzare solo i nomi dei file e la data e l&#8217;ora dell&#8217;ultima modifica:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view only file names with modification date and time\n<\/span>file_info[c(\" <span style=\"color: #ff0000;\">mtime<\/span> \")]\n\n                                  mtime\nmy_list.csv 2022-04-21 09:40:01\nmy_test.csv 2022-04-21 09:42:25\ndf1.csv 2022-04-21 10:48:24\ndf2.csv 2022-04-21 10:48:30\ndf3.csv 2022-04-21 10:48:34\ntest.csv 2022-09-07 09:07:34\nmy_data.csv 2022-09-09 09:02:21\nplayers_data.csv 2023-01-06 09:44:12\nbasketball_data.csv 2023-01-06 11:07:43\nuneven_data.csv 2023-01-06 14:02:17\nplayer_stats.csv 2023-04-11 09:07:20\nteam_info.csv 2023-04-11 09:07:21\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Se lo desideri, puoi anche visualizzare solo i nomi dei file per data:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view only file names\n<\/span>rownames(file_info)\n\n [1] \"my_list.csv\" \"my_test.csv\" \"df1.csv\" \"df2.csv\" \"df3.csv\"            \n [6] \"test.csv\" \"my_data.csv\" \"players_data.csv\" \"basketball_data.csv\" \"uneven_data.csv\"    \n[11] \"player_stats.csv\" \"team_info.csv\"  \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I dodici nomi di file CSV sono ordinati per data.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Correlato:<\/strong> <a href=\"https:\/\/statorials.org\/it\/r-elenco-dei-file\/\" target=\"_blank\" rel=\"noopener\">Come utilizzare la funzione list.files() in R (4 esempi)<\/a><\/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 eseguire altre attivit\u00e0 comuni in R:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><a href=\"https:\/\/statorials.org\/it\/leggere-il-file-zip-in-r\/\" target=\"_blank\" rel=\"noopener\">Come leggere i file Zip in R<\/a><br \/> <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\/importare-excel-in-r\/\" target=\"_blank\" rel=\"noopener\">Come importare file Excel in R<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi di base per elencare i file nella directory di lavoro corrente in R per data: #extract all CSV files in working directory file_info = file. info ( list.files (pattern=&#8221; *.csv &#8220;)) #sort files based on mtime (date and time modification) file_info = file_info[ with (file_info, order (as. POSIXct (mtime))), [&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 elencare i file per data in R (con esempio) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come elencare i file per data in R, con un esempio.\" \/>\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-elenca-i-file-per-data\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come elencare i file per data in R (con esempio) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come elencare i file per data in R, con un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-10T14:25:59+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=\"3 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/\",\"url\":\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/\",\"name\":\"Come elencare i file per data in R (con esempio) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-10T14:25:59+00:00\",\"dateModified\":\"2023-07-10T14:25:59+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come elencare i file per data in R, con un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come elencare i file per data 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 elencare i file per data in R (con esempio) \u2013 Statorials","description":"Questo tutorial spiega come elencare i file per data in R, con un esempio.","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-elenca-i-file-per-data\/","og_locale":"it_IT","og_type":"article","og_title":"Come elencare i file per data in R (con esempio) \u2013 Statorials","og_description":"Questo tutorial spiega come elencare i file per data in R, con un esempio.","og_url":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/","og_site_name":"Statorials","article_published_time":"2023-07-10T14:25:59+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"3 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/","url":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/","name":"Come elencare i file per data in R (con esempio) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-10T14:25:59+00:00","dateModified":"2023-07-10T14:25:59+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come elencare i file per data in R, con un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/r-elenca-i-file-per-data\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come elencare i file per data 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\/4504"}],"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=4504"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/4504\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=4504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=4504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=4504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}