{"id":2962,"date":"2023-07-19T21:30:46","date_gmt":"2023-07-19T21:30:46","guid":{"rendered":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/"},"modified":"2023-07-19T21:30:46","modified_gmt":"2023-07-19T21:30:46","slug":"argumentos-nao-conformes-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/","title":{"rendered":"Como corrigir um erro em r: argumentos n\u00e3o compat\u00edveis"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Uma mensagem de erro que voc\u00ea pode encontrar ao usar R \u00e9:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error in matrix2 %*% matrix1: non-conformable arguments\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Este erro ocorre quando voc\u00ea tenta multiplicar duas matrizes, mas o n\u00famero de <strong>colunas<\/strong> na matriz esquerda n\u00e3o corresponde ao n\u00famero de <strong>linhas<\/strong> na matriz direita.<\/span><\/p>\n<p> <span style=\"color: #000000;\">O exemplo a seguir mostra como resolver esse erro na pr\u00e1tica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Como reproduzir o erro<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Suponha que temos as duas matrizes a seguir em R:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create first matrix\n<span style=\"color: #000000;\">mat1 &lt;- matrix(1:10, nrow= <span style=\"color: #008000;\">5<\/span> ) \n\nmat1\n\n     [,1] [,2]\n[1,] 1 6\n[2,] 2 7\n[3,] 3 8\n[4,] 4 9\n[5,] 5 10\n\n<span style=\"color: #008080;\">#create second matrix\n<\/span>mat2 &lt;- matrix(1:6, nrow= <span style=\"color: #008000;\">2<\/span> )\n\nmat2\n\n     [,1] [,2] [,3]\n[1,] 1 3 5\n[2,] 2 4 6<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Agora suponha que tentamos multiplicar a segunda matriz pela primeira matriz:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to multiply second matrix by first matrix\n<span style=\"color: #000000;\">mate2 %*% mate1\n\nError in mat2 %*% mat1: non-conformable arguments\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Recebemos um erro porque o n\u00famero de <strong>colunas<\/strong> (3) na matriz esquerda n\u00e3o corresponde ao n\u00famero de <strong>linhas<\/strong> (5) na matriz direita.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Como evitar o erro<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Para evitar o erro <strong>de argumentos n\u00e3o conformes<\/strong> , voc\u00ea deve multiplicar a primeira matriz pela segunda 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;\">multiply first matrix by second matrix<\/span>\nmate1 %*% mate2\n\n     [,1] [,2] [,3]\n[1,] 13 27 41\n[2,] 16 34 52\n[3,] 19 41 63\n[4,] 22 48 74\n[5,] 25 55 85\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Observe que somos capazes de multiplicar ambas as matrizes com \u00eaxito e sem erros porque o n\u00famero de <strong>colunas<\/strong> (2) na matriz esquerda corresponde ao n\u00famero de <strong>linhas<\/strong> (2) na matriz direita.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Tamb\u00e9m podemos usar a fun\u00e7\u00e3o <strong>dim()<\/strong> para exibir o n\u00famero de colunas e linhas em cada matriz:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#view dimensions of first matrix\n<span style=\"color: #000000;\">dim(mat1)\n\n[1] 5 2\n\n<span style=\"color: #008080;\">#view dimensions of second matrix\n<\/span>dim(mat2)\n\n[1] 2 3\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">A partir desta sa\u00edda podemos ver:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">A primeira matriz possui <strong>5<\/strong> linhas e <strong>2<\/strong> colunas.<\/span><\/li>\n<li> <span style=\"color: #000000;\">A segunda matriz possui <strong>2<\/strong> linhas e <strong>3<\/strong> colunas.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Isso mostra claramente que temos que usar a primeira matriz \u00e0 esquerda e a segunda matriz \u00e0 direita ao multiplicar, pois a primeira matriz possui <strong>2<\/strong> colunas e a segunda matriz possui <strong>2<\/strong> linhas.<\/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 corrigir outros erros comuns no R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/r-argumentos-implicam-um-numero-diferente-de-linhas\/\" target=\"_blank\" rel=\"noopener\">Como consertar em R: argumentos envolvem diferentes n\u00fameros de linhas<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/erro-dplyr-em-selecionar-argumentos-nao-utilizados\/\" target=\"_blank\" rel=\"noopener\">Como corrigir em R: erro na sele\u00e7\u00e3o de argumentos n\u00e3o utilizados<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/r-substituicao-no-comprimento-zero\/\" target=\"_blank\" rel=\"noopener\">Como reparar em R: a substitui\u00e7\u00e3o tem comprimento zero<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Uma mensagem de erro que voc\u00ea pode encontrar ao usar R \u00e9: Error in matrix2 %*% matrix1: non-conformable arguments Este erro ocorre quando voc\u00ea tenta multiplicar duas matrizes, mas o n\u00famero de colunas na matriz esquerda n\u00e3o corresponde ao n\u00famero de linhas na matriz direita. O exemplo a seguir mostra como resolver esse erro na [&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-2962","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 corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, 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\/argumentos-nao-conformes-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, com um exemplo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T21:30:46+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\/argumentos-nao-conformes-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/\",\"name\":\"Como corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-19T21:30:46+00:00\",\"dateModified\":\"2023-07-19T21:30:46+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, com um exemplo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como corrigir um erro em r: argumentos n\u00e3o compat\u00edveis\"}]},{\"@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 corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais","description":"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, 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\/argumentos-nao-conformes-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais","og_description":"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, com um exemplo.","og_url":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/","og_site_name":"Statorials","article_published_time":"2023-07-19T21:30:46+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\/argumentos-nao-conformes-r\/","url":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/","name":"Como corrigir um erro em R: argumentos n\u00e3o compat\u00edveis - Estatoriais","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-19T21:30:46+00:00","dateModified":"2023-07-19T21:30:46+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como corrigir o erro de argumentos n\u00e3o conformes em R, com um exemplo.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/argumentos-nao-conformes-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como corrigir um erro em r: argumentos n\u00e3o compat\u00edveis"}]},{"@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\/2962","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=2962"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2962\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}