{"id":1969,"date":"2023-07-24T06:38:44","date_gmt":"2023-07-24T06:38:44","guid":{"rendered":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/"},"modified":"2023-07-24T06:38:44","modified_gmt":"2023-07-24T06:38:44","slug":"creare-una-lista-vuota-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/","title":{"rendered":"Come creare un elenco vuoto in r (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi per creare un elenco vuoto in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create empty list with length of zero\n<span style=\"color: #000000;\">empty_list &lt;- list()<\/span>\n\n#create empty list of length 10<\/span>\nempty_list &lt;- vector(mode=' <span style=\"color: #ff0000;\">list<\/span> ', length= <span style=\"color: #008000;\">10<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare queste funzioni nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: crea un elenco vuoto in R con lunghezza pari a zero<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un elenco vuoto di lunghezza zero in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create empty list\n<\/span>empty_list &lt;- list()\n\n<span style=\"color: #008080;\">#verify that empty_list is of class 'list'<\/span>\nclass(empty_list)\n\n[1] \"list\"\n\n<span style=\"color: #008080;\">#view length of list<\/span>\nlength(empty_list)\n\n[1] 0\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il risultato \u00e8 un elenco di lunghezza 0.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: crea un elenco vuoto in R con una lunghezza specifica<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un elenco vuoto di lunghezza 8 in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create empty list of length 8\n<\/span>empty_list &lt;- vector(mode=' <span style=\"color: #ff0000;\">list<\/span> ', length= <span style=\"color: #008000;\">8<\/span> )\n\n<span style=\"color: #008080;\">#verify that empty_list is of class 'list'<\/span>\nclass(empty_list)\n\n[1] \"list\"\n\n<span style=\"color: #008080;\">#view list<\/span>\nempty_list\n[[1]]\nNULL\n\n[[2]]\nNULL\n\n[[3]]\nNULL\n\n[[4]]\nNULL\n\n[[5]]\nNULL\n\n[[6]]\nNULL\n\n[[7]]\nNULL\n\n[[8]]\nNULL\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Il risultato \u00e8 una lista di lunghezza 8 in cui ogni elemento della lista \u00e8 NULL.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: aggiungere valori a un elenco vuoto in R<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Uno dei motivi pi\u00f9 comuni per creare un elenco vuoto \u00e8 riempirlo poi di valori utilizzando un ciclo.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un elenco vuoto e quindi riempirlo con valori:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create empty list of length 8\n<\/span>empty_list &lt;- vector(mode=' <span style=\"color: #ff0000;\">list<\/span> ', length= <span style=\"color: #008000;\">8<\/span> )\n<span style=\"color: #008080;\">\n#get length of list\n<span style=\"color: #000000;\">len &lt;- length(empty_list)\n\n<span style=\"color: #008080;\">#define values to append to list\n<\/span>new &lt;- c(3, 5, 12, 14, 17, 18, 18, 20)\n\n<span style=\"color: #008080;\">#fill values in list\n<\/span>i = 1\n<span style=\"color: #008000;\">while<\/span> (i &lt;= length(new)) {\n    empty_list[[i]] &lt;- new[i]\n    i &lt;- i + 1\n}\n\n<span style=\"color: #008080;\">#display updated list\n<\/span>empty_list\n\n<\/span><\/span>[[1]]\n[1] 3\n\n[[2]]\n[1] 5\n\n[[3]]\n[1] 12\n\n[[4]]\n[1] 14\n\n[[5]]\n[1] 17\n\n[[6]]\n[1] 18\n\n[[7]]\n[1] 18\n\n[[8]]\n[1] 20\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Nota che l&#8217;elenco vuoto \u00e8 ora popolato con i nuovi valori che abbiamo specificato.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/creare-un-dataframe-vuoto-in-r\/\" target=\"_blank\" rel=\"noopener\">Come creare un frame di dati vuoto in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/aggiungi-alla-lista\/\" target=\"_blank\" rel=\"noopener\">Come aggiungere valori all&#8217;elenco in R<\/a><br \/><a href=\"https:\/\/statorials.org\/it\/converti-la-lista-nel-vettore-r\/\" target=\"_blank\" rel=\"noopener\">Come convertire una lista in un vettore in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi per creare un elenco vuoto in R: #create empty list with length of zero empty_list &lt;- list() #create empty list of length 10 empty_list &lt;- vector(mode=&#8217; list &#8216;, length= 10 ) I seguenti esempi mostrano come utilizzare queste funzioni nella pratica. Esempio 1: crea un elenco vuoto in R [&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 creare una lista vuota in R (con esempi) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come creare un elenco vuoto 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\/creare-una-lista-vuota-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come creare una lista vuota in R (con esempi) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come creare un elenco vuoto in R, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T06:38:44+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=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/\",\"url\":\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/\",\"name\":\"Come creare una lista vuota in R (con esempi) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-24T06:38:44+00:00\",\"dateModified\":\"2023-07-24T06:38:44+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come creare un elenco vuoto in R, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come creare un elenco vuoto 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":"Come creare una lista vuota in R (con esempi) \u2013 Statorials","description":"Questo tutorial spiega come creare un elenco vuoto 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\/creare-una-lista-vuota-in-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come creare una lista vuota in R (con esempi) \u2013 Statorials","og_description":"Questo tutorial spiega come creare un elenco vuoto in R, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T06:38:44+00:00","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\/creare-una-lista-vuota-in-r\/","url":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/","name":"Come creare una lista vuota in R (con esempi) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-24T06:38:44+00:00","dateModified":"2023-07-24T06:38:44+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come creare un elenco vuoto in R, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/creare-una-lista-vuota-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come creare un elenco vuoto 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\/1969"}],"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=1969"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1969\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}