{"id":3000,"date":"2023-07-19T17:08:03","date_gmt":"2023-07-19T17:08:03","guid":{"rendered":"https:\/\/statorials.org\/pt\/funcao-r-gato\/"},"modified":"2023-07-19T17:08:03","modified_gmt":"2023-07-19T17:08:03","slug":"funcao-r-gato","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/funcao-r-gato\/","title":{"rendered":"Como usar a fun\u00e7\u00e3o cat() em r para concatenar objetos"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">A fun\u00e7\u00e3o <strong>cat()<\/strong> em R pode ser usada para concatenar v\u00e1rios objetos em R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>cat(..., file = \"\", sep = \" \", append = FALSE))<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Ouro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>\u2026<\/strong> : Objetos para concatenar<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>file<\/strong> : nome do arquivo para o qual enviar a sa\u00edda<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>sep<\/strong> : Separador para usar entre objetos<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>anexar<\/strong> : se deseja adicionar a sa\u00edda ao arquivo existente ou criar um novo arquivo<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar esta fun\u00e7\u00e3o de diferentes maneiras.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 1: Use cat() para concatenar objetos<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>cat()<\/strong> para concatenar tr\u00eas strings em R:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings\n<\/span>cat(\"hey\", \"there\", \"everyone\")\n\nhey there everyone\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">As tr\u00eas strings s\u00e3o concatenadas, com cada string separada por um espa\u00e7o.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 2: Use cat() para concatenar objetos com um separador personalizado<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>cat()<\/strong> para concatenar tr\u00eas strings em R, usando um h\u00edfen como separador:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings, using dash as separator\n<\/span>cat(\"hey\", \"there\", \"everyone\", sep=\" <span style=\"color: #ff0000;\">-<\/span> \")\n\nhey-there-everyone\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Ou poder\u00edamos usar &#8220;\\n&#8221; como separador, indicando que cada string deve ser separada por uma nova linha:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings, using new line as separator\n<\/span>cat(\"hey\", \"there\", \"everyone\", sep=\" <span style=\"color: #ff0000;\">\\n<\/span> \")\n\nhey\nthere\neveryone<\/strong><\/span><\/pre>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 3: Use cat() para concatenar objetos e exibir os resultados em um arquivo<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>cat()<\/strong> para concatenar tr\u00eas strings em R e exibir os resultados em um arquivo de texto:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings and output results to txt file\n<\/span>cat(\"hey\", \"there\", \"everyone\", sep=\" <span style=\"color: #ff0000;\">\\n<\/span> \", file=\" <span style=\"color: #ff0000;\">my_data.txt<\/span> \")\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Posso ent\u00e3o navegar at\u00e9 meu <a href=\"https:\/\/statorials.org\/pt\/setwd-getwd-em-r\/\" target=\"_blank\" rel=\"noopener\">diret\u00f3rio de trabalho atual<\/a> e visualizar o conte\u00fado deste arquivo de texto:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25886 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/chat11.jpg\" alt=\"\" width=\"386\" height=\"358\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Tamb\u00e9m poder\u00edamos exibir os resultados em um arquivo CSV:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings and output results to CSV file\n<\/span>cat(\"hey\", \"there\", \"everyone\", sep=\" <span style=\"color: #ff0000;\">\\n<\/span> \", file=\" <span style=\"color: #ff0000;\">my_data.csv<\/span> \")\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Posso ent\u00e3o navegar at\u00e9 meu <a href=\"https:\/\/statorials.org\/pt\/setwd-getwd-em-r\/\" target=\"_blank\" rel=\"noopener\">diret\u00f3rio de trabalho atual<\/a> e visualizar o conte\u00fado deste arquivo de texto:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25887 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/chat12.jpg\" alt=\"\" width=\"455\" height=\"423\" srcset=\"\" sizes=\"auto, \"><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 4: Use cat() para concatenar objetos e anexar os resultados ao arquivo<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Podemos usar a fun\u00e7\u00e3o <strong>cat()<\/strong> para concatenar tr\u00eas strings em R e anexar os resultados a um arquivo CSV existente:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#concatenate three strings and output results to CSV file\n<\/span>cat(\"hey\", \"there\", \"everyone\", sep=\" <span style=\"color: #ff0000;\">\\n<\/span> \", file=\" <span style=\"color: #ff0000;\">my_data.csv<\/span> \")\n\n<span style=\"color: #008080;\">#append results of this concatenation to first file<\/span>\ncat(\"how\", \"are\", \"you\", sep=\" <span style=\"color: #ff0000;\">\\n<\/span> \", file=\" <span style=\"color: #ff0000;\">my_data.csv<\/span> \", append= <span style=\"color: #008000;\">TRUE<\/span> )\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Posso ent\u00e3o navegar at\u00e9 meu <a href=\"https:\/\/statorials.org\/pt\/setwd-getwd-em-r\/\" target=\"_blank\" rel=\"noopener\">diret\u00f3rio de trabalho atual<\/a> e visualizar o conte\u00fado deste arquivo CSV:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-25888 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/chat13.jpg\" alt=\"\" width=\"449\" height=\"440\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Observe que os resultados da segunda fun\u00e7\u00e3o <strong>cat()<\/strong> foram adicionados ao arquivo criado pela primeira fun\u00e7\u00e3o <strong>cat()<\/strong> .<\/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 usar outras fun\u00e7\u00f5es comuns em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/funcao-sprintf-r\/\" target=\"_blank\" rel=\"noopener\">Como usar a fun\u00e7\u00e3o sprintf em R para imprimir strings formatadas<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/funcao-strsplit-em-r\/\" target=\"_blank\" rel=\"noopener\">Como usar a fun\u00e7\u00e3o strsplit() em R para dividir elementos de string<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/funcao-de-substring-em-r\/\" target=\"_blank\" rel=\"noopener\">Como usar a fun\u00e7\u00e3o substring() em R para extrair uma substring<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A fun\u00e7\u00e3o cat() em R pode ser usada para concatenar v\u00e1rios objetos em R. Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica: cat(&#8230;, file = &#8220;&#8221;, sep = &#8221; &#8220;, append = FALSE)) Ouro: \u2026 : Objetos para concatenar file : nome do arquivo para o qual enviar a sa\u00edda sep : Separador para usar entre [&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-3000","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 usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, 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\/funcao-r-gato\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/funcao-r-gato\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T17:08:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/chat11.jpg\" \/>\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=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/funcao-r-gato\/\",\"url\":\"https:\/\/statorials.org\/pt\/funcao-r-gato\/\",\"name\":\"Como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-19T17:08:03+00:00\",\"dateModified\":\"2023-07-19T17:08:03+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/funcao-r-gato\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/funcao-r-gato\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/funcao-r-gato\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como usar a fun\u00e7\u00e3o cat() em r para concatenar objetos\"}]},{\"@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 usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials","description":"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, 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\/funcao-r-gato\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/funcao-r-gato\/","og_site_name":"Statorials","article_published_time":"2023-07-19T17:08:03+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/chat11.jpg"}],"author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/funcao-r-gato\/","url":"https:\/\/statorials.org\/pt\/funcao-r-gato\/","name":"Como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-19T17:08:03+00:00","dateModified":"2023-07-19T17:08:03+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o cat() em R para concatenar objetos, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/funcao-r-gato\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/funcao-r-gato\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/funcao-r-gato\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como usar a fun\u00e7\u00e3o cat() em r para concatenar objetos"}]},{"@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\/3000","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=3000"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/3000\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=3000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=3000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=3000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}