Error in ggplot when I try to Knit in HTML

Trying to Knit and I get an error stating "No such file or directory" for ggplot. When I delete that chunk to knit again, it gives same error but for histogram in document. Both code chunks for the charts execute in html but time to knit and I get this error. How do I resolve this?

The error I see in your image says could not find function "ggplot". The usual cause for that is that you have not loaded ggplot2 with the library function.

library(ggplot2)

Do you have that line of code in the file that you knit?

Caveat: I'm an R newbie so bear with me. Thank you kindly.

Is ggplot not part of tidyverse? I installed the tidyverse packages and library in my console script so I assumed it would knit since I was creating a markdown with the same dataset. The code chunk below is what I want generated. The scatterplot generates well but time to knit and I get errors.

Just to try, I ran the library(ggplot2) function in Markdown, tried to knit, and same error still.

ggplot(data = netflix_titles, aes(x = release_year , y = type)) + geom_point() + geom_jitter()

When you knit an Rmd document the code gets executed in a clean environment other than the one you are currently working on so you have to include all needed library calls, as well as the code for importing any external data set, in your Rmd file itself.

Hi @Ena , I have this problem when forget put the correct libraries in the script.
Im suggest you create a new chunk, maybe in the first part of document and put all the libraries of work.

library(tidyverse)
library(readxl)
library(factoextra)

Something like that.

Ahhh...thank you. I've done that...but issue still persists. Now, it's saying my csv can't be found but when I entered the read_csv function into a code chunk, I got an error.

Thank you! I didn't know one had to reexecute in a clean environment. Alas, it's now saying that my csv file cannot be found. When I entered the read_csv in a code chunk, I got an error upon knitting. I can't do library(csv file) since it isn't a package so how can i circumvent this?

Thank you again for your assist.

This is how my csv reads:

read_csv("netflix_titles.csv", header = TRUE, sep = ",") and I get an error.

1 Like

I am working on the same dataset to try to learn. I do not yet know the answer to your question. How did you convert the date_added column from col_character to a date column?

In this case you dont load the object netflix_titles. Verify the initial lines when you load the data.

You can use file.choose() for select the file. And put the correct pahth of her file.

file.choose()

d<-read_excel("C:\\Users\\MiguelAngel\\Documents\\R Miguelo\\Guillermo (Circular Packing)\\oms.xls")

In this case this is the path in my laptop.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.