{"id":2279,"date":"2023-07-22T23:13:33","date_gmt":"2023-07-22T23:13:33","guid":{"rendered":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/"},"modified":"2023-07-22T23:13:33","modified_gmt":"2023-07-22T23:13:33","slug":"combinar-dois-vetores-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/","title":{"rendered":"Como combinar dois vetores em r (com exemplos)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar qualquer um dos seguintes m\u00e9todos para combinar dois vetores em R:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 1: Combine dois vetores em um vetor<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #000000;\">new_vector &lt;- c(vector1, vector2)<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 2: Combine dois vetores em uma matriz<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>new_matrix &lt;- cbind(vector1, vector2)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 3: Combine dois vetores em um quadro de dados<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>new_df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (vector1, vector2)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar cada m\u00e9todo na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>M\u00e9todo 1: Combine dois vetores em um vetor<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como combinar dois vetores em um \u00fanico novo vetor:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#definevectors<\/span>\nvector1 &lt;- c(1, 2, 3, 4, 5)\nvector2 &lt;- c(6, 7, 8, 9, 10)\n\n<span style=\"color: #008080;\">#combine two vectors into one vector\n<\/span>new_vector &lt;- c(vector1, vector2)\n\n<span style=\"color: #008080;\">#view resulting vector\n<\/span>new_vector\n\n[1] 1 2 3 4 5 6 7 8 9 10\n<\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>M\u00e9todo 2: Combine dois vetores em uma matriz<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como combinar dois vetores em uma matriz:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#definevectors\n<\/span>vector1 &lt;- c(1, 2, 3, 4, 5)\nvector2 &lt;- c(6, 7, 8, 9, 10)\n\n<span style=\"color: #008080;\">#combine two vectors into matrix\n<\/span>new_matrix &lt;- cbind(vector1, vector2)\n\n<span style=\"color: #008080;\">#view resulting matrix\n<\/span>new_matrix\n\n     vector1 vector2\n[1,] 1 6\n[2,] 2 7\n[3,] 3 8\n[4,] 4 9\n[5,] 5 10\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\"><strong>Relacionado:<\/strong> <a href=\"https:\/\/statorials.org\/pt\/cbind-em-r\/\" target=\"_blank\" rel=\"noopener\">Como usar cbind em R (com exemplos)<\/a><\/span><\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>M\u00e9todo 3: Combine dois vetores em um quadro de dados<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como combinar dois vetores em um quadro de dados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#definevectors\n<\/span>vector1 &lt;- c(1, 2, 3, 4, 5)\nvector2 &lt;- c(6, 7, 8, 9, 10)\n\n<span style=\"color: #008080;\">#combine two vectors into data frame\n<\/span>new_df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (vector1, vector2)\n\n<span style=\"color: #008080;\">#view resulting data frame\n<\/span>new_df\n\n  vector1 vector2\n1 1 6\n2 2 7\n3 3 8\n4 4 9\n5 5 10<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Observe que cada vetor original agora \u00e9 uma coluna \u00fanica no quadro de dados resultante.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir explicam como realizar outras opera\u00e7\u00f5es comuns em R:<\/span><\/p>\n<p> Como combinar listas em R<br \/> <a href=\"https:\/\/statorials.org\/pt\/r-combine-duas-colunas-em-uma\/\" target=\"_blank\" rel=\"noopener\">Como combinar duas colunas em uma em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/r-combine-dois-quadros-de-dados-com-colunas-diferentes\/\" target=\"_blank\" rel=\"noopener\">Como combinar dois quadros de dados em R com colunas diferentes<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar qualquer um dos seguintes m\u00e9todos para combinar dois vetores em R: M\u00e9todo 1: Combine dois vetores em um vetor new_vector &lt;- c(vector1, vector2) M\u00e9todo 2: Combine dois vetores em uma matriz new_matrix &lt;- cbind(vector1, vector2) M\u00e9todo 3: Combine dois vetores em um quadro de dados new_df &lt;- data. frame (vector1, vector2) Os [&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":[],"class_list":["post-2279","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como combinar dois vetores em R (com exemplos) - Estatoriais<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.\" \/>\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\/pt\/combinar-dois-vetores-em-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como combinar dois vetores em R (com exemplos) - Estatoriais\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-22T23:13:33+00:00\" \/>\n<meta name=\"author\" content=\"Dr. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\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\/pt\/combinar-dois-vetores-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/\",\"name\":\"Como combinar dois vetores em R (com exemplos) - Estatoriais\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-22T23:13:33+00:00\",\"dateModified\":\"2023-07-22T23:13:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como combinar dois vetores em r (com exemplos)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como combinar dois vetores em R (com exemplos) - Estatoriais","description":"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.","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\/pt\/combinar-dois-vetores-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como combinar dois vetores em R (com exemplos) - Estatoriais","og_description":"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/","og_site_name":"Statorials","article_published_time":"2023-07-22T23:13:33+00:00","author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/","url":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/","name":"Como combinar dois vetores em R (com exemplos) - Estatoriais","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-22T23:13:33+00:00","dateModified":"2023-07-22T23:13:33+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como combinar dois vetores em R, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/combinar-dois-vetores-em-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como combinar dois vetores em r (com exemplos)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=2279"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2279\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}