GGPLOT2 - Don't know how to automatically pick scale for object of type function - ERROR


#1

I am not sure what this error refers to:
Don’t know how to automatically pick scale for object of type function.

I dont seem got reason in stackoverflow for the error. Can some one please clarify on this ?

My Data Set:

  1. I did an aggregate from a data set and got the above resulted data as data frame.
    and I am trying to plot the frequency (y axis) with class as X axis.

#upscale_class is the resultant data frame, contains same data as in image.
ggplot(data=upscale_class, aes(x=class, y=BusCentTOT)) +
geom_bar(stat=“identity”)

I get an error :
Don’t know how to automatically pick scale for object of type function. Defaulting to continuous.
Error in data.frame(x = .Primitive(“class”), y = c(80, 1717, 629, 793, : **
** arguments imply differing number of rows: 0, 7

  1. But when I manually create a data frame with values as shown below:
    da <- data.frame(
    class = factor(c(“Economy Class”," Luxury Class",“Midscale Class”,“NA”,“Upper Midscale Class”,“Upper Upscale Class”,“Upscale Class”),
    ),
    BusCentTOT = c(80, 1717,629,793,761,2415,1593)
    )
    class(upscale_class)
    ggplot(da=upscale_class, aes(x=class, y=BusCentTOT)) +
    geom_bar(stat=“identity”)

I get the graph plotted.

Can some one please guide me on this, both the data frame has same data,

  1. both with same values and columns
  2. first data frame is derived from a main data set where as second one is manually created.
  3. all the data types of columns are same for both the data frame.

Not sure why I am unable to plot for first data frame ?

Can some one help me on this ?

Thank you in advance!


#2

I got it resolved, small typo mistake.

Thank you!