0
votes

I'm using R Markdown to write a report and using this code to create a graph:

ggplot(dd, aes(x =timestamp, y =eventType)) + 
geom_line()

I am getting the error message below:

Error in ggplot(dd, aes(x = timestamp, y = eventType)): could not find function "ggplot"

I have tried to specify the library(ggplot2) but that didn't help. Can anybody suggest anything? If I run the r code on its own it works fine. If I tried to knit as pdf it doesn't work. Thanks

1
Where exactly did you put the library(ggplot2) command? Do you have it in the markdown document somewhere? It's easier to help you if you include a simple reproducible example with sample input that can be used to test and verify possible solutions. - MrFlick
I have tried to add the library(ggplot2) just above the code. Also, I have another r script file where I run my r code before adding to the r markdown file. How do i copy a sample of my data into the reply? The link you have provided doesn't show this - user5576922

1 Answers

0
votes

Have you tried running this code

     ggplot2::ggplot(dd, ggplot2::aes(x =timestamp, y =eventType)) + 
     ggplot2::geom_line()