{"id":3718,"date":"2023-07-15T23:13:17","date_gmt":"2023-07-15T23:13:17","guid":{"rendered":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/"},"modified":"2023-07-15T23:13:17","modified_gmt":"2023-07-15T23:13:17","slug":"r-tabela-inclui-na","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/","title":{"rendered":"Como criar uma tabela e incluir valores na em r"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Por padr\u00e3o, a fun\u00e7\u00e3o <strong>table()<\/strong> em R cria uma tabela de valores de frequ\u00eancia, mas n\u00e3o inclui a frequ\u00eancia dos valores NA.<\/span><\/p>\n<p> <span style=\"color: #000000;\">No entanto, voc\u00ea pode usar os seguintes m\u00e9todos para criar uma tabela e incluir valores NA:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 1: Crie uma tabela e sempre mostre a quantidade de valores NA<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>table(df$my_column, useNA = \" <span style=\"color: #ff0000;\">always<\/span> \")<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>M\u00e9todo 2: Crie uma tabela e exiba apenas o n\u00famero de valores NA se houver algum<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>table(df$my_column, useNA = \" <span style=\"color: #ff0000;\">ifany<\/span> \")\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar cada m\u00e9todo na pr\u00e1tica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Exemplo 1: Crie uma tabela e sempre exiba a quantidade de valores NA<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Suponha que temos o seguinte quadro de dados em R que cont\u00e9m informa\u00e7\u00f5es sobre v\u00e1rios jogadores de basquete:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team=c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'),\n                 points=c(20, 25, 14, 18, 19, 12, 12, 15))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n  team points\n1 to 20\n2 to 25\n3 to 14\n4 to 18\n5 B 19\n6 B 12\n7 B 12\n8 B 15\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Podemos usar a seguinte sintaxe para criar uma tabela de frequ\u00eancia de valores na coluna da <strong>equipe<\/strong> e exibir o n\u00famero de valores NA, existindo ou n\u00e3o:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create frequency table of values in team column, including NA values\n<\/span>table(df$team, useNA = \" <span style=\"color: #ff0000;\">always<\/span> \")\n\n   AB &lt;NA&gt;\n   4 4 0 \n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Observe que a tabela resultante mostra que existem valores <strong>0<\/strong> NA na coluna da equipe do quadro de dados.<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Como usamos o argumento <strong>useNA = \u201calways\u201d<\/strong> , a tabela ainda mostrava o n\u00famero de valores de NA mesmo que n\u00e3o houvesse nenhum.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Exemplo 2: Crie uma tabela e s\u00f3 exiba a quantidade de valores NA se houver algum<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Vamos supor novamente que temos o seguinte quadro de dados em R que cont\u00e9m informa\u00e7\u00f5es sobre v\u00e1rios jogadores de basquete:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create data frame\n<\/span>df &lt;- data. <span style=\"color: #3366ff;\">frame<\/span> (team=c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'),\n                 points=c(20, 25, 14, 18, 19, 12, 12, 15))\n\n#view data frame\ndf\n\n  team points\n1 to 20\n2 to 25\n3 to 14\n4 to 18\n5 B 19\n6 B 12\n7 B 12\n8 B 15\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Podemos usar a seguinte sintaxe para criar uma tabela para a frequ\u00eancia dos valores na coluna <strong>da equipe<\/strong> e exibir apenas o n\u00famero de valores NA, se houver:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create frequency table of values in team column, including NA values if any exist\n<\/span>table(df$team, useNA = \" <span style=\"color: #ff0000;\">ifany<\/span> \")\n\nAB\n4 4<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Observe que a tabela resultante mostra a frequ\u00eancia dos valores \u201cA\u201d e \u201cB\u201d na coluna <strong>da equipe<\/strong> , mas n\u00e3o mostra a frequ\u00eancia dos valores NA, pois n\u00e3o h\u00e1 nenhum.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir explicam como realizar outras opera\u00e7\u00f5es comuns em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/mesa-bidirecional-em-r\/\" target=\"_blank\" rel=\"noopener\">Como criar uma tabela bidirecional em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/estatologia-explica-conceitos-de-forma-simples-e-direta-facilitamos-o-aprendizado-de-estatistica\/\" target=\"_blank\" rel=\"noopener\">Como converter array em matriz em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/converter-quadro-de-dados-da-tabela-para-r\/\" target=\"_blank\" rel=\"noopener\">Como converter uma tabela em um quadro de dados em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Por padr\u00e3o, a fun\u00e7\u00e3o table() em R cria uma tabela de valores de frequ\u00eancia, mas n\u00e3o inclui a frequ\u00eancia dos valores NA. No entanto, voc\u00ea pode usar os seguintes m\u00e9todos para criar uma tabela e incluir valores NA: M\u00e9todo 1: Crie uma tabela e sempre mostre a quantidade de valores NA table(df$my_column, useNA = &#8221; [&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-3718","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 criar uma tabela e incluir valores NA em R \u2013 Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.\" \/>\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\/r-tabela-inclui-na\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como criar uma tabela e incluir valores NA em R \u2013 Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-15T23:13:17+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=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/\",\"url\":\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/\",\"name\":\"Como criar uma tabela e incluir valores NA em R \u2013 Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-15T23:13:17+00:00\",\"dateModified\":\"2023-07-15T23:13:17+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como criar uma tabela e incluir valores na 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 criar uma tabela e incluir valores NA em R \u2013 Estatologia","description":"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.","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\/r-tabela-inclui-na\/","og_locale":"pt_PT","og_type":"article","og_title":"Como criar uma tabela e incluir valores NA em R \u2013 Estatologia","og_description":"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.","og_url":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/","og_site_name":"Statorials","article_published_time":"2023-07-15T23:13:17+00:00","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\/r-tabela-inclui-na\/","url":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/","name":"Como criar uma tabela e incluir valores NA em R \u2013 Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-15T23:13:17+00:00","dateModified":"2023-07-15T23:13:17+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como criar uma tabela em R e incluir valores NA, com um exemplo.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/r-tabela-inclui-na\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como criar uma tabela e incluir valores na 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\/3718","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=3718"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/3718\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=3718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=3718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=3718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}