Problems plotting graph in R with ggplot2

Asked

Viewed 226 times

-1

I need to plot a graph from a file’s data. txt, the data import part is ok, however, when I use the ggplot function, it says that could not find "ggplot". Below is the code I’m trying to use:


require("ggdata")
library(haven)
library(readxl)
library(ggplot2)
library(ggalt)


dados <- read.csv(file = "C:/Users/gabri/OneDrive/Documentos/Amostra03.txt", sep = "")

model <- lm(x~y,dados)

ggplot(dados,aes(x=x,y=y)) geom_point()

I had already managed to fix this mistake, however I lost the code by carelessness and do not remember the procedure I did.

  • Gabriel, good morning! As Voce did not give many details, what I can observe that this wrong is the lack of + between ggplot and geom_point. Correct would be: ggplot(dados,aes(x=x,y=y)) + geom_point().

  • Without the dados the example is not reproducible. It is not necessary to load as many packages and the lm is completely unnecessary. Good questions must have data and code minimum to reproduce the problem.

1 answer

0


Gabriel, it is always important to provide your database to increase the chances of receiving a response.

Observing your code, the error is in the form you wrote.

Instead of:

ggplot(dados,aes(x=x,y=y)) geom_point()

You must add one +:

ggplot(dados,aes(x=x,y=y)) + geom_point()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.