2021年2月3日星期三

stat_smooth not displayed on the plot when filtering data

So i have a scatter plot with a line of best fit. This is using the r script editor on Power BI. When i filter my data and limit it(say based on location/city) it's fine. However when i go deeeper, say i select a specific area - suddenly my line of best fit doesn't work.

At first i thought it was the data i was choosing, so that the smaller the data, it won't display. However that's not the case. See the two screenshots below. Is there a way to fix it, so that it displays the line/curve of best fit regardless of how many datapoints i choose?

Image1

Image2

here's my formula

library(plotly)  library(ggplot2)  p <- ggplot(dataset, aes(x = Quantity, y = Price))   p +   geom_point(colour = "red") +   stat_smooth(method = "nls", formula = 'y~(a*x^b)', start = list(a=1,b=-1), se=FALSE)  
https://stackoverflow.com/questions/66038728/stat-smooth-not-displayed-on-the-plot-when-filtering-data February 04, 2021 at 10:51AM

没有评论:

发表评论