{"id":1854,"date":"2023-07-24T17:45:19","date_gmt":"2023-07-24T17:45:19","guid":{"rendered":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/"},"modified":"2023-07-24T17:45:19","modified_gmt":"2023-07-24T17:45:19","slug":"convertire-la-matrice-nel-vettore-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/","title":{"rendered":"Come convertire una matrice in un vettore in r (con esempi)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi per convertire una matrice in un vettore in R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert matrix to vector (sorted by columns) using c()<\/span>\nnew_vector &lt;- c(my_matrix)\n\n<span style=\"color: #008080;\">#convert matrix to vector (sorted by rows) using c()\n<\/span>new_vector &lt;- c(t(my_matrix))\n\n<span style=\"color: #008080;\">#convert matrix to vector (sorted by columns) using as.vector()\n<\/span>new_vector &lt;- as. <span style=\"color: #3366ff;\">vector<\/span> (my_matrix)\n\n<span style=\"color: #008080;\">#convert matrix to vector (sorted by rows) using as.vector()\n<\/span>new_vector &lt;- as. <span style=\"color: #3366ff;\">vector<\/span> (t(my_matrix))\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che le funzioni <strong>c()<\/strong> e <strong>as.vettore()<\/strong> restituiranno risultati identici.<\/span><\/p>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare nella pratica ciascuna di queste funzioni con la seguente matrice:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create matrix<\/span>\nmy_matrix &lt;- matrix(1:20, nrow = <span style=\"color: #008000;\">5<\/span> )\n\n<span style=\"color: #008080;\">#display matrix\n<\/span>my_matrix\n\n     [,1] [,2] [,3] [,4]\n[1,] 1 6 11 16\n[2,] 2 7 12 17\n[3,] 3 8 13 18\n[4,] 4 9 14 19\n[5,] 5 10 15 20\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: convertire matrice in vettore (ordinato per colonne) utilizzando la funzione c()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come convertire una matrice in un vettore (ordinato per colonne) utilizzando la funzione <strong>c()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert matrix to vector (sorted by columns)<\/span>\nnew_vector &lt;- c(my_matrix)\n\n<span style=\"color: #008080;\">#display vector\n<\/span>new_vector\n\n[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: convertire matrice in vettore (ordinato per righe) utilizzando la funzione c()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come convertire una matrice in un vettore (ordinato per righe) utilizzando la funzione <strong>c()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert matrix to vector (sorted by rows)<\/span>\nnew_vector &lt;- c(t(my_matrix))\n\n<span style=\"color: #008080;\">#display vector\n<\/span>new_vector\n\n[1] 1 6 11 16 2 7 12 17 3 8 13 18 4 9 14 19 5 10 15 20\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: convertire matrice in vettore (ordinato per colonne) utilizzando la funzione as.vettore()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come convertire una matrice in un vettore (ordinato per colonne) utilizzando la funzione <strong>as.vettore()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert matrix to vector (sorted by columns)<\/span>\nnew_vector &lt;- as. <span style=\"color: #3366ff;\">vector<\/span> (my_matrix)\n\n<span style=\"color: #008080;\">#display vector\n<\/span>new_vector\n\n[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 4: convertire una matrice in un vettore (ordinato per righe) utilizzando la funzione as.vettore()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come convertire una matrice in un vettore (ordinato per righe) utilizzando la funzione <strong>as.vettore()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert matrix to vector (sorted by rows)<\/span>\nnew_vector &lt;- as. <span style=\"color: #3366ff;\">vector<\/span> (t(my_matrix))\n\n<span style=\"color: #008080;\">#display vector\n<\/span>new_vector\n\n[1] 1 6 11 16 2 7 12 17 3 8 13 18 4 9 14 19 5 10 15 20<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/convertire-lelenco-nel-frame-di-dati-r\/\" target=\"_blank\" rel=\"noopener\">Come convertire una lista in un frame di dati in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/carattere-numerico-in-r\/\" target=\"_blank\" rel=\"noopener\">Come convertire un carattere in numerico in R<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/carattere-da-fattorizzare-in-r\/\" target=\"_blank\" rel=\"noopener\">Come convertire un carattere in un fattore in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi per convertire una matrice in un vettore in R: #convert matrix to vector (sorted by columns) using c() new_vector &lt;- c(my_matrix) #convert matrix to vector (sorted by rows) using c() new_vector &lt;- c(t(my_matrix)) #convert matrix to vector (sorted by columns) using as.vector() new_vector &lt;- as. vector (my_matrix) #convert matrix [&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 convertire una matrice in un vettore in R (con esempi)<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come convertire una matrice in un vettore 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\/convertire-la-matrice-nel-vettore-r\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come convertire una matrice in un vettore in R (con esempi)\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come convertire una matrice in un vettore in R, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T17:45:19+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\/convertire-la-matrice-nel-vettore-r\/\",\"url\":\"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/\",\"name\":\"Come convertire una matrice in un vettore in R (con esempi)\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-24T17:45:19+00:00\",\"dateModified\":\"2023-07-24T17:45:19+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come convertire una matrice in un vettore in R, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come convertire una matrice in un vettore 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 convertire una matrice in un vettore in R (con esempi)","description":"Questo tutorial spiega come convertire una matrice in un vettore 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\/convertire-la-matrice-nel-vettore-r\/","og_locale":"it_IT","og_type":"article","og_title":"Come convertire una matrice in un vettore in R (con esempi)","og_description":"Questo tutorial spiega come convertire una matrice in un vettore in R, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T17:45:19+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\/convertire-la-matrice-nel-vettore-r\/","url":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/","name":"Come convertire una matrice in un vettore in R (con esempi)","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-24T17:45:19+00:00","dateModified":"2023-07-24T17:45:19+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come convertire una matrice in un vettore in R, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/convertire-la-matrice-nel-vettore-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come convertire una matrice in un vettore 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\/1854"}],"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=1854"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1854\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}