I'm trying to make a chart of the frequency of the items in a dataset but I'm having this error when ploting.
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (39123): x
This is the model of the data I'm using:
product_id order_id product_name
1 41899 330425 Oreo Ice Cream Sandwiches
2 122580 1707573 Mint Chip
3 146891 622568 Coffee Ice Cream
4 134292 1284843 Belgian Milk Chocolate Gelato
5 146530 2693694 Variety Pack Ice Cream Bars
The str output of the dataframe is (top 5 values):
'data.frame': 5 obs. of 3 variables:
$ product_id : int 41899 122580 146891 134292 146530
$ order_id : int 330425 1707573 622568 1284843 2693694
$ product_name: Factor w/ 49688 levels "'Swingtop' Premium Lager",..: 28573 25871 10030 4236 47274
I've tried several changes to the plot code, but I got different errors.
This is the code I'm using.
orders_group <- group_by(orders_products,order_id)
orders_summ <- as.data.frame(summarise(orders_group, n_items = count(product_name)))
ggplot(orders_summ,aes(x=n_items))+
geom_histogram(stat="count")+#geom_histogram(fill="indianred", bins = 100000) +
geom_rug()+
coord_cartesian(xlim=c(0,80))+
scale_fill_manual(values = getPalette(colourCount))