{"id":1811,"date":"2023-07-24T21:38:24","date_gmt":"2023-07-24T21:38:24","guid":{"rendered":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/"},"modified":"2023-07-24T21:38:24","modified_gmt":"2023-07-24T21:38:24","slug":"funcao-de-tabela-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/","title":{"rendered":"Como usar a fun\u00e7\u00e3o de tabela em r (com exemplos)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">A fun\u00e7\u00e3o <strong>table()<\/strong> em R pode ser usada para criar tabelas de frequ\u00eancia rapidamente.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Este tutorial fornece exemplos de uso desta fun\u00e7\u00e3o com o seguinte 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> (player = c('AJ', 'Bob', 'Chad', 'Dan', 'Eric', 'Frank'),\n                 position = c('A', 'B', 'B', 'B', 'B', 'A'),\n                 points = c(1, 2, 2, 1, 0, 0))\n\n<span style=\"color: #008080;\">#view data frame\n<\/span>df\n\n  player position points\n1 AJ A 1\n2 Bob B 2\n3 Chad B 2\n4 Dan B 1\n5 Eric B 0\n6 Frank A 0<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 1: Tabela de frequ\u00eancia para uma vari\u00e1vel<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como criar uma tabela de frequ\u00eancia para a vari\u00e1vel de <strong>posi\u00e7\u00e3o<\/strong> em nosso quadro de dados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate frequency table for <em>position<\/em> variable\n<\/span>table(df$position)\n\nAB\n2 4\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Pelo resultado podemos observar:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">2 jogadores no quadro de dados t\u00eam uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d<\/span><\/li>\n<li> <span style=\"color: #000000;\">4 jogadores no bloco de dados t\u00eam uma posi\u00e7\u00e3o de &#8221; <strong>B<\/strong> &#8220;<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 2: Tabela de propor\u00e7\u00f5es de frequ\u00eancia para uma vari\u00e1vel<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar <strong>prop.table()<\/strong> para criar uma tabela de frequ\u00eancia proporcional para a vari\u00e1vel de <strong>posi\u00e7\u00e3o<\/strong> em nosso quadro de dados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate frequency table of proportions for <em>position<\/em> variable\n<\/span>prop. <span style=\"color: #3366ff;\">table<\/span> (table(df$position))\n\n        AB\n0.3333333 0.6666667\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Pelo resultado podemos observar:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">33,33% dos jogadores no data frame t\u00eam uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d<\/span><\/li>\n<li> <span style=\"color: #000000;\">66,67% dos jogadores no data frame t\u00eam uma posi\u00e7\u00e3o \u201c <strong>B<\/strong> \u201d<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Observe que numa tabela de propor\u00e7\u00f5es a soma das propor\u00e7\u00f5es ser\u00e1 sempre igual a 1.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 3: Tabela de frequ\u00eancia para duas vari\u00e1veis<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como criar uma tabela de frequ\u00eancia para a vari\u00e1vel <strong>posi\u00e7\u00e3o<\/strong> e <strong>pontos<\/strong> em nosso quadro de dados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate frequency table for <em>position<\/em> and <em>points<\/em> variable\n<\/span>table(df$position, df$points)\n\n    0 1 2\n  A 1 1 0\n  B 1 1 2\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Pelo resultado podemos observar:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">1 jogador no data frame tem uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>0<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">1 jogador no data frame tem uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>1<\/strong> ponto<\/span><\/li>\n<li> <span style=\"color: #000000;\">0 jogadores no data frame t\u00eam uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>2<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">1 jogador no data frame tem uma posi\u00e7\u00e3o &#8221; <strong>B<\/strong> &#8221; e <strong>0<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">1 jogador no data frame tem uma posi\u00e7\u00e3o &#8221; <strong>B<\/strong> &#8221; e <strong>1<\/strong> ponto<\/span><\/li>\n<li> <span style=\"color: #000000;\">2 jogadores no data frame t\u00eam uma posi\u00e7\u00e3o &#8221; <strong>B<\/strong> &#8221; e <strong>2<\/strong> pontos<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo 4: Tabela de propor\u00e7\u00f5es de frequ\u00eancia para duas vari\u00e1veis<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como criar uma tabela de frequ\u00eancia de propor\u00e7\u00e3o de aspecto para a vari\u00e1vel de <strong>posi\u00e7\u00e3o<\/strong> e <strong>pontos<\/strong> em nosso quadro de dados:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#calculate frequency table of proportions for <em>position<\/em> and <em>points<\/em> variable\n<\/span>prop. <span style=\"color: #3366ff;\">table<\/span> (table(df$position, df$points))\n\n            0 1 2\n  A 0.1666667 0.1666667 0.0000000\n  B 0.1666667 0.1666667 0.3333333\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Pelo resultado podemos observar:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">16,67% dos jogadores no data frame t\u00eam posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>0<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">16,67% dos jogadores no data frame t\u00eam posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>1<\/strong> ponto<\/span><\/li>\n<li> <span style=\"color: #000000;\">0% dos jogadores no data frame t\u00eam uma posi\u00e7\u00e3o \u201c <strong>A<\/strong> \u201d e <strong>2<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">16,67% dos jogadores no data frame t\u00eam posi\u00e7\u00e3o \u201c <strong>B<\/strong> \u201d e <strong>0<\/strong> pontos<\/span><\/li>\n<li> <span style=\"color: #000000;\">16,67% dos jogadores no data frame t\u00eam posi\u00e7\u00e3o \u201c <strong>B<\/strong> \u201d e <strong>1<\/strong> ponto<\/span><\/li>\n<li> <span style=\"color: #000000;\">33,3% dos jogadores no data frame t\u00eam posi\u00e7\u00e3o \u201c <strong>B<\/strong> \u201d e <strong>2<\/strong> pontos<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Observe que tamb\u00e9m podemos usar a fun\u00e7\u00e3o <strong>options()<\/strong> para especificar o n\u00famero de casas decimais a serem exibidas na tabela de propor\u00e7\u00f5es:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#only display two decimal places\n<span style=\"color: #000000;\">options(digits= <span style=\"color: #008000;\">2<\/span> )<\/span>\n\n#calculate frequency table of proportions for <em>position<\/em> and <em>points<\/em> variable\n<\/span>prop. <span style=\"color: #3366ff;\">table<\/span> (table(df$position, df$points))\n\n       0 1 2\n  A 0.17 0.17 0.00\n  B 0.17 0.17 0.33<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/pt\/tabela-de-frequencia-relativa-em-r\/\" target=\"_blank\" rel=\"noopener\">Como criar tabelas de frequ\u00eancia relativa em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/histograma-de-frequencia-relativa-r\/\" target=\"_blank\" rel=\"noopener\">Como criar um histograma de frequ\u00eancia relativa em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A fun\u00e7\u00e3o table() em R pode ser usada para criar tabelas de frequ\u00eancia rapidamente. Este tutorial fornece exemplos de uso desta fun\u00e7\u00e3o com o seguinte quadro de dados em R: #create data frame df &lt;- data. frame (player = c(&#8216;AJ&#8217;, &#8216;Bob&#8217;, &#8216;Chad&#8217;, &#8216;Dan&#8217;, &#8216;Eric&#8217;, &#8216;Frank&#8217;), position = c(&#8216;A&#8217;, &#8216;B&#8217;, &#8216;B&#8217;, &#8216;B&#8217;, &#8216;B&#8217;, &#8216;A&#8217;), points = [&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-1811","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 de tabela em R (com exemplos)<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o table() 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\/funcao-de-tabela-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 de tabela em R (com exemplos)\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o table() em R, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T21:38:24+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=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/\",\"name\":\"Como usar a fun\u00e7\u00e3o de tabela em R (com exemplos)\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-24T21:38:24+00:00\",\"dateModified\":\"2023-07-24T21:38:24+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o table() em R, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/funcao-de-tabela-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 de tabela 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 usar a fun\u00e7\u00e3o de tabela em R (com exemplos)","description":"Este tutorial explica como usar a fun\u00e7\u00e3o table() 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\/funcao-de-tabela-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar a fun\u00e7\u00e3o de tabela em R (com exemplos)","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o table() em R, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/","og_site_name":"Statorials","article_published_time":"2023-07-24T21:38:24+00:00","author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/","url":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/","name":"Como usar a fun\u00e7\u00e3o de tabela em R (com exemplos)","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-24T21:38:24+00:00","dateModified":"2023-07-24T21:38:24+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o table() em R, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/funcao-de-tabela-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/funcao-de-tabela-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 de tabela 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\/1811","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=1811"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1811\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}