DS4PS / cpp-526-spr-2021

Course shell for Foundations of Data Science I
https://ds4ps.org/cpp-526-spr-2021/
MIT License
1 stars 2 forks source link

Code Through Question #17

Open sjone128 opened 3 years ago

sjone128 commented 3 years ago

I'm having a problem when I try to knit my code through document. I am using the starwars data set in the ggplot package. All of my chunks work but when I try to knit it together, this is the error.

Line 22 Error in ggplot(data = starwars) : object 'starwars' not found Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> ggplot Execution halted

Here is the offending chunk. It is also the first time I call ggplot in the library or the starwars data set.

library(ggplot2)
ggplot(data = starwars) + 
   geom_bar(mapping = aes(x = eye_color))

The chunk runs fine, I'm not sure what I'm missing.

thanks!

jamisoncrawford commented 3 years ago

Cool! If you type help(starwars) or ?starwars, you'll see in the first lines of the built-in documentation that starwars is from package dplyr - so try library(dplyr) in the beginning of your script.

image

See if that knits and let us know!

sjone128 commented 3 years ago

@jamisoncrawford That worked great! Thanks. :)

jamisoncrawford commented 3 years ago

Reopening for visibility *