{"id":1987,"date":"2023-07-24T04:47:54","date_gmt":"2023-07-24T04:47:54","guid":{"rendered":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/"},"modified":"2023-07-24T04:47:54","modified_gmt":"2023-07-24T04:47:54","slug":"leia-delim-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/","title":{"rendered":"Como usar a fun\u00e7\u00e3o read.delim em r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar a fun\u00e7\u00e3o <strong>read.delim()<\/strong> para ler arquivos de texto delimitados em R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>read.delim(arquivo, cabe\u00e7alho=TRUE, set=&#8217;\\t&#8217;)<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Ouro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>arquivo<\/strong> : a localiza\u00e7\u00e3o do arquivo.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>header<\/strong> : indica se a primeira linha representa o cabe\u00e7alho da tabela. O padr\u00e3o \u00e9 verdadeiro.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>sep<\/strong> : O delimitador da tabela. O padr\u00e3o \u00e9 tabula\u00e7\u00e3o (\\t).<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">O exemplo a seguir mostra como usar esta fun\u00e7\u00e3o na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo: como usar read.delim em R<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Vamos come\u00e7ar criando um quadro de dados em R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team=c('Mavs', 'Mavs', 'Spurs', 'Nets'),\n                 dots=c(99, 90, 84, 96),\n                 assists=c(22, 19, 16, 20),\n                 rebounds=c(30, 39, 42, 26))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n   team points assists rebounds\n1 Mavs 99 22 30\n2 Mavs 90 19 39\n3 Spurs 84 16 42\n4 Nets 96 20 26<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Ent\u00e3o vamos usar a fun\u00e7\u00e3o <strong>write.table()<\/strong> para exportar o quadro de dados para um arquivo de texto delimitado por tabula\u00e7\u00f5es:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#export to tab-delimited text file\n<\/span>write.write. <span style=\"color: #3366ff;\">table<\/span> (df, ' <span style=\"color: #ff0000;\">my_data.txt<\/span> ', quote= <span style=\"color: #008000;\">FALSE<\/span> , sep=' <span style=\"color: #ff0000;\">\\t<\/span> ', <span style=\"color: #3366ff;\">row.names<\/span> = <span style=\"color: #008000;\">FALSE<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Posso ent\u00e3o navegar at\u00e9 onde exportei os dados e visualizar o arquivo de texto:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-18732 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/read_delim1.png\" alt=\"\" width=\"456\" height=\"389\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Posso ent\u00e3o usar a fun\u00e7\u00e3o <strong>read.delim()<\/strong> para ler o arquivo de texto:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#read in tab-delimited text file\n<\/span>my_df &lt;- read. <span style=\"color: #3366ff;\">delim<\/span> (' <span style=\"color: #ff0000;\">my_data.txt<\/span> ')\n\n<span style=\"color: #008080;\">#view data<\/span>\nmy_df\n   team points assists rebounds\n1 Mavs 99 22 30\n2 Mavs 90 19 39\n3 Spurs 84 16 42\n4 Nets 96 20 26<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">O quadro de dados corresponde ao quadro de dados que criamos anteriormente.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Observe que o delimitador de tabela padr\u00e3o para a fun\u00e7\u00e3o <strong>read.delim()<\/strong> \u00e9 uma tabula\u00e7\u00e3o (\\t).<\/span><\/p>\n<p> <span style=\"color: #000000;\">Portanto, o c\u00f3digo a seguir produz os mesmos resultados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#read in tab-delimited text file\n<\/span>my_df &lt;- read. <span style=\"color: #3366ff;\">delim<\/span> (' <span style=\"color: #ff0000;\">my_data.txt<\/span> ', sep=' <span style=\"color: #ff0000;\">\\t<\/span> ')\n\n<span style=\"color: #008080;\">#view data<\/span>\nmy_df\n   team points assists rebounds\n1 Mavs 99 22 30\n2 Mavs 90 19 39\n3 Spurs 84 16 42\n4 Nets 96 20 26<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Notas sobre o uso de read.delim()<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Observe que voc\u00ea pode usar a fun\u00e7\u00e3o <strong>getwd()<\/strong> para obter o diret\u00f3rio de trabalho atual e descobrir onde o primeiro bloco de dados foi exportado.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Voc\u00ea tamb\u00e9m pode usar a fun\u00e7\u00e3o <strong>setwd()<\/strong> se quiser alterar a localiza\u00e7\u00e3o do diret\u00f3rio de trabalho atual.<\/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 importar outros tipos de arquivo para R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/inserir-dados-em-r\/\" target=\"_blank\" rel=\"noopener\">Como inserir manualmente dados brutos em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/importar-csv-para-r\/\" target=\"_blank\" rel=\"noopener\">Como importar arquivos CSV para R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/importar-excel-para-r\/\" target=\"_blank\" rel=\"noopener\">Como importar arquivos Excel para R (passo a passo)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar a fun\u00e7\u00e3o read.delim() para ler arquivos de texto delimitados em R. Esta fun\u00e7\u00e3o usa a seguinte sintaxe b\u00e1sica: read.delim(arquivo, cabe\u00e7alho=TRUE, set=&#8217;\\t&#8217;) Ouro: arquivo : a localiza\u00e7\u00e3o do arquivo. header : indica se a primeira linha representa o cabe\u00e7alho da tabela. O padr\u00e3o \u00e9 verdadeiro. sep : O delimitador da tabela. O padr\u00e3o [&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-1987","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 read.delim em R \u2013 Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.\" \/>\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\/leia-delim-em-r\/\" \/>\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 read.delim em R \u2013 Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/leia-delim-em-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T04:47:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/read_delim1.png\" \/>\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\/leia-delim-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/leia-delim-em-r\/\",\"name\":\"Como usar a fun\u00e7\u00e3o read.delim em R \u2013 Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-24T04:47:54+00:00\",\"dateModified\":\"2023-07-24T04:47:54+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/leia-delim-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/leia-delim-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/leia-delim-em-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como usar a fun\u00e7\u00e3o read.delim em r\"}]},{\"@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 read.delim em R \u2013 Estatologia","description":"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.","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\/leia-delim-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar a fun\u00e7\u00e3o read.delim em R \u2013 Estatologia","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.","og_url":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T04:47:54+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/read_delim1.png"}],"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\/leia-delim-em-r\/","url":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/","name":"Como usar a fun\u00e7\u00e3o read.delim em R \u2013 Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-24T04:47:54+00:00","dateModified":"2023-07-24T04:47:54+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o read.delim em R, com um exemplo completo.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/leia-delim-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/leia-delim-em-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como usar a fun\u00e7\u00e3o read.delim em r"}]},{"@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\/1987","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=1987"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1987\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}