{"id":1772,"date":"2023-07-25T01:26:42","date_gmt":"2023-07-25T01:26:42","guid":{"rendered":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/"},"modified":"2023-07-25T01:26:42","modified_gmt":"2023-07-25T01:26:42","slug":"r-indice-di-errore-fuori-range","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/","title":{"rendered":"Come riparare in r: indice fuori limite"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un errore comune che potresti riscontrare in R \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error in x[, 4]: subscript out of bounds\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questo errore si verifica quando si tenta di accedere a una colonna o riga di una matrice che non esiste.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo tutorial mostra i passaggi esatti che puoi eseguire per risolvere questo errore, utilizzando la seguente matrice come esempio:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#make this example reproducible<\/span>\nset. <span style=\"color: #3366ff;\">seeds<\/span> (0)\n\n<span style=\"color: #008080;\">#create matrix with 10 rows and 3 columns<\/span>\nx = matrix(data = sample. <span style=\"color: #3366ff;\">int<\/span> (100, 30), nrow = 10, ncol = 3)\n\n<span style=\"color: #008080;\">#print matrix\n<\/span><span style=\"color: #993300;\">print<\/span> (x)\n\n      [,1] [,2] [,3]\n [1,] 14 51 96\n [2,] 68 85 44\n [3,] 39 21 33\n [4,] 1 54 35\n [5,] 34 74 70\n [6,] 87 7 86\n [7,] 43 73 42\n [8,] 100 79 38\n [9,] 82 37 20\n[10,] 59 92 28\n<\/strong><\/pre>\n<h3> <strong>Esempio n. 1: indice fuori intervallo (con linee)<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il seguente codice tenta di accedere all&#8217;undicesima riga della matrice, che non esiste:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to display 11th row of matrix<\/span>\nx[11, ]\n\nError in x[11, ]: subscript out of bounds\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Poich\u00e9 l&#8217;undicesima riga della matrice non esiste, otteniamo l&#8217;errore <strong>dell&#8217;indice fuori dai limiti<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se non sappiamo quante righe ci sono nella matrice, possiamo usare la funzione <strong>nrow()<\/strong> per scoprirlo:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display number of rows in matrix<\/span>\nnrow(x)\n\n[1] 10\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere che ci sono solo 10 righe nella matrice. Pertanto, possiamo utilizzare solo numeri inferiori o uguali a 10 per accedere alle righe.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, possiamo utilizzare la seguente sintassi per visualizzare la decima riga della matrice:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display 10th row of matrix<\/span>\nx[10, ]\n\n[1] 59 92 28\n<\/strong><\/pre>\n<h3> <strong>Esempio n.2: indice fuori intervallo (con colonne)<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il seguente codice tenta di accedere alla quarta colonna della matrice, che non esiste:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to display 4th column of matrix<\/span>\nx[, 4]\n\nError in x[, 4]: subscript out of bounds\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Poich\u00e9 la quarta colonna della matrice non esiste, otteniamo l&#8217;errore <strong>dell&#8217;indice fuori dai limiti<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se non sappiamo quante colonne contiene la matrice, possiamo usare la funzione <strong>ncol()<\/strong> per scoprirlo:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display number of columns in matrix<\/span>\nncol(x)\n\n[1] 3\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Vediamo che ci sono solo 3 colonne nella matrice. Pertanto, possiamo utilizzare solo numeri inferiori o uguali a 3 per accedere alle colonne.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, possiamo utilizzare la seguente sintassi per visualizzare la terza colonna della matrice:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display 3rd column of matrix<\/span>\nx[, 3]\n\n[1] 96 44 33 35 70 86 42 38 20 28<\/strong><\/pre>\n<h3> <strong>Esempio n.3: indice fuori intervallo (righe e colonne)<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il seguente codice tenta di accedere al valore dell&#8217;undicesima riga e della quarta colonna della matrice, che non esiste:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to display value in 11th row and 4th column<\/span>\nx[11, 4]\n\nError in x[11, 4]: subscript out of bounds\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Poich\u00e9 non esistono n\u00e9 l&#8217;undicesima riga n\u00e9 la quarta colonna della matrice, otteniamo l&#8217;errore <strong>dell&#8217;indice fuori dai limiti<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Se non sappiamo quante righe e colonne ci sono nella matrice, possiamo usare la funzione <strong>dim()<\/strong> per scoprirlo:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display number of rows and columns in matrix<\/span>\ndim(x)\n\n[1] 10 3\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Vediamo che nella matrice ci sono solo 10 righe e 3 colonne. Pertanto, possiamo utilizzare solo numeri inferiori o uguali a questi valori quando accediamo a righe e colonne.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, possiamo utilizzare la seguente sintassi per visualizzare il valore nella decima riga e nella terza colonna della matrice:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display value in 10th row and 3rd column of matrix<\/span>\nx[10, 3]\n\n[1] 28\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\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\">Come risolvere in R: la lunghezza di un oggetto pi\u00f9 lungo non \u00e8 un multiplo della lunghezza di un oggetto pi\u00f9 corto<\/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 errore comune che potresti riscontrare in R \u00e8: Error in x[, 4]: subscript out of bounds Questo errore si verifica quando si tenta di accedere a una colonna o riga di una matrice che non esiste. Questo tutorial mostra i passaggi esatti che puoi eseguire per risolvere questo errore, utilizzando la seguente matrice come [&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 riparare in R: accenno fuori limite - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.\" \/>\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-indice-di-errore-fuori-range\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come riparare in R: accenno fuori limite - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T01:26:42+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-indice-di-errore-fuori-range\/\",\"url\":\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/\",\"name\":\"Come riparare in R: accenno fuori limite - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-25T01:26:42+00:00\",\"dateModified\":\"2023-07-25T01:26:42+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come riparare in r: indice fuori limite\"}]},{\"@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 riparare in R: accenno fuori limite - Statorials","description":"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.","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-indice-di-errore-fuori-range\/","og_locale":"it_IT","og_type":"article","og_title":"Come riparare in R: accenno fuori limite - Statorials","og_description":"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.","og_url":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/","og_site_name":"Statorials","article_published_time":"2023-07-25T01:26:42+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-indice-di-errore-fuori-range\/","url":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/","name":"Come riparare in R: accenno fuori limite - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-25T01:26:42+00:00","dateModified":"2023-07-25T01:26:42+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come correggere il seguente errore in R: indice fuori intervallo.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/r-indice-di-errore-fuori-range\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come riparare in r: indice fuori limite"}]},{"@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\/1772"}],"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=1772"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1772\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}