{"id":1874,"date":"2023-07-24T15:36:23","date_gmt":"2023-07-24T15:36:23","guid":{"rendered":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/"},"modified":"2023-07-24T15:36:23","modified_gmt":"2023-07-24T15:36:23","slug":"r-nao-foi-possivel-encontrar-a-funcao-ggplot","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/","title":{"rendered":"Como consertar em r: n\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d;"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Um erro que voc\u00ea pode encontrar no R \u00e9:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>Error in ggplot(df, aes(x = x, y = y)): could not find function \"ggplot\"\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Este erro ocorre quando voc\u00ea tenta criar um gr\u00e1fico usando o pacote de visualiza\u00e7\u00e3o de dados <a href=\"https:\/\/ggplot2.tidyverse.org\/\" target=\"_blank\" rel=\"noopener\">ggplot2<\/a> , mas n\u00e3o consegue carregar o pacote primeiro.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Este tutorial explica cinco maneiras poss\u00edveis de corrigir esse erro.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Como reproduzir este erro<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Suponha que executemos o seguinte c\u00f3digo 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> (x=c(1, 2, 4, 5, 7, 8, 9, 10),\n                 y=c(12, 17, 27, 39, 50, 57, 66, 80))\n\n<span style=\"color: #008080;\">#create scatterplot of x vs. y\n<\/span>ggplot(df, aes(x=x, y=y)) +\n  geom_point()\n\nError in ggplot(df, aes(x = x, y = y)): could not find function \"ggplot\"\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Estamos recebendo um erro porque n\u00e3o carregamos o pacote ggplot2 em nosso ambiente R atual.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Corre\u00e7\u00e3o potencial n\u00ba 1: carregue o pacote ggplot2<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">A maneira mais comum de corrigir esse erro \u00e9 simplesmente carregar o pacote ggplot2 usando a fun\u00e7\u00e3o <strong>biblioteca()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #000000;\"><span style=\"color: #993300;\">library<\/span> (ggplot2)<\/span>\n<\/span>\n<span style=\"color: #008080;\">#create scatterplot of x vs. y\n<\/span>ggplot(df, aes(x=x, y=y)) +\n  geom_point()<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Em muitos casos, isso corrigir\u00e1 o erro.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Corre\u00e7\u00e3o potencial n\u00ba 2: instale ggplot2<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se a corre\u00e7\u00e3o n\u00ba 1 n\u00e3o funcionar, pode ser necess\u00e1rio instalar o ggplot2 usando a fun\u00e7\u00e3o <strong>install.packages()<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #993300;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#install ggplot2<\/span>\ninstall.packages(\" <span style=\"color: #ff0000;\">ggplot2<\/span> \")<\/span>\n\n<span style=\"color: #008080;\">#load ggplot2<\/span>\nlibrary<\/span> (ggplot2)\n\n<\/span><span style=\"color: #008080;\">#create scatterplot of x vs. y\n<\/span>ggplot(df, aes(x=x, y=y)) +\n  geom_point()\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Corre\u00e7\u00e3o potencial n\u00ba 3: instale ggplot2 com depend\u00eancias<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se as corre\u00e7\u00f5es anteriores n\u00e3o funcionarem, pode ser necess\u00e1rio instalar o ggplot2 e tamb\u00e9m especificar a instala\u00e7\u00e3o de todos os pacotes dos quais o ggplot2 depende:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #993300;\"><span style=\"color: #008080;\">#install ggplot2 and all dependencies<\/span>\n<span style=\"color: #000000;\">install.packages(\" <span style=\"color: #ff0000;\">ggplot2<\/span> \", dependencies= <span style=\"color: #008000;\">TRUE<\/span> )\n<\/span>\n<span style=\"color: #008080;\">#load ggplot2<\/span>\nlibrary<\/span> (ggplot2)\n\n<\/span><span style=\"color: #008080;\">#create scatterplot of x vs. y\n<\/span>ggplot(df, aes(x=x, y=y)) +\n  geom_point()<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Corre\u00e7\u00e3o potencial n\u00ba 4: remover e reinstalar ggplot2<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se as corre\u00e7\u00f5es anteriores n\u00e3o funcionarem, pode ser necess\u00e1rio remover completamente a vers\u00e3o atual do ggplot2 e reinstal\u00e1-la:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #993300;\"><span style=\"color: #008080;\">#remove ggplot2\n<span style=\"color: #000000;\">remove.packages(\" <span style=\"color: #ff0000;\">ggplot2<\/span> \")<\/span>\n\n#install ggplot2<\/span>\n<span style=\"color: #000000;\">install.packages(\" <span style=\"color: #ff0000;\">ggplot2<\/span> \")\n<\/span>\n<span style=\"color: #008080;\">#load ggplot2<\/span>\nlibrary<\/span> (ggplot2)\n\n<\/span><span style=\"color: #008080;\">#create scatterplot of x vs. y\n<\/span>ggplot(df, aes(x=x, y=y)) +\n  geom_point()<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Corre\u00e7\u00e3o potencial n\u00ba 5: execute o trecho de c\u00f3digo correto<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se nenhuma das corre\u00e7\u00f5es anteriores funcionar, talvez voc\u00ea s\u00f3 precise verificar se est\u00e1 executando o c\u00f3digo correto em R que realmente instala e carrega o pacote ggplot2.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Em muitas circunst\u00e2ncias, voc\u00ea pode simplesmente esquecer de executar as duas linhas que instalam <em>e<\/em> carregam o ggplot2 em R.<\/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\/ggplot2-nao-pode-usar-gg-com-um-unico-argumento\/\" target=\"_blank\" rel=\"noopener\">Como corrigir em R: n\u00e3o \u00e9 poss\u00edvel usar `+.gg()` com um \u00fanico argumento<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/r-numero-incorreto-de-indices-na-matriz\/\" target=\"_blank\" rel=\"noopener\">Como corrigir em R: n\u00famero incorreto de \u00edndices na matriz<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/r-indice-de-erro-fora-do-intervalo\/\" target=\"_blank\" rel=\"noopener\">Como reparar em R: \u00edndice fora dos limites<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Um erro que voc\u00ea pode encontrar no R \u00e9: Error in ggplot(df, aes(x = x, y = y)): could not find function &#8220;ggplot&#8221; Este erro ocorre quando voc\u00ea tenta criar um gr\u00e1fico usando o pacote de visualiza\u00e7\u00e3o de dados ggplot2 , mas n\u00e3o consegue carregar o pacote primeiro. Este tutorial explica cinco maneiras poss\u00edveis de [&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-1874","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 em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com 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\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como corrigir em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T15:36:23+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-nao-foi-possivel-encontrar-a-funcao-ggplot\/\",\"url\":\"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/\",\"name\":\"Como corrigir em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-24T15:36:23+00:00\",\"dateModified\":\"2023-07-24T15:36:23+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como consertar em r: n\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d;\"}]},{\"@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 em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d","description":"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com 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\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/","og_locale":"pt_PT","og_type":"article","og_title":"Como corrigir em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d","og_description":"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com exemplos.","og_url":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/","og_site_name":"Statorials","article_published_time":"2023-07-24T15:36:23+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-nao-foi-possivel-encontrar-a-funcao-ggplot\/","url":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/","name":"Como corrigir em R: N\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-24T15:36:23+00:00","dateModified":"2023-07-24T15:36:23+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como resolver o seguinte erro em R: N\u00e3o foi poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d, com exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/r-nao-foi-possivel-encontrar-a-funcao-ggplot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como consertar em r: n\u00e3o \u00e9 poss\u00edvel encontrar a fun\u00e7\u00e3o \u201cggplot\u201d;"}]},{"@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\/1874","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=1874"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1874\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}