For some reason when I do the following:
Fruit <- c(rep("Apple",3),rep("Orange",5))
Bug <- c("worm","spider","spider","worm","worm","worm","worm","spider")
Numbers <- runif(8)
df <- data.frame(Fruit,Bug,Numbers)
For factor count
bar.plot <- function(dat,j,c){
ggplot(dat, aes(j, ..count..)) +
geom_bar(aes(fill = c), position = "dodge")
}
bar.plot(df,Fruit,Bug)
I get
Don't know how to automatically pick scale for object of type function. Defaulting to continuous
Error in eval(expr, envir, enclos) : object 'j' not found
I am mostly concerned about the second line of the error Error in eval... Anyone know why this is happening? I have a lot of bar plots to make so this function would make my life a lot easier.