Reputation: 11
This is the code I have been attempting to run with the following result - Error: attempt to apply non-function
# install packages
install.packages("Ecdat")
install.packages("gapminder")
# run libraries
library(gapminder)
library(Ecdat)
library(ggplot2)
library(dplyr)
View(mtcars)
c <- ggplot(mtcars, aes(x = cyl,
y=mpg))
c + geom_col(color = blue, fill =
green) +
(main = "Car Milage Data") (xlab =
"Number of Cylinders") (ylab =
"Miles Per Gallon")
Upvotes: 0
Views: 934
Reputation: 8826
I noted 3 things:
c
as the name of the object, and it is one of the base R functionsgeom_col
need to be charactersmain
, xlab
and ylab
did not have a "connector" such as +
I way to do your plot is
ggplot(mtcars, aes(x = cyl,y = mpg)) +
geom_col(color = "blue", fill = "green")+
labs(
x = "Number of Cylinders",
y = "Miles Per Gallon",
title = "Car Milage Data"
)
Upvotes: 2