I am running the kaggle competition on the house prices estimate following the notebook provided by a professionals.You can check it on
https://www.kaggle.com/erikbruin/house-prices-lasso-xgboost-and-a-detailed-eda/report#missing-data-label-encoding-and-factorizing-variables
When annotate the bar plot,the code is shown below
ggplot(all[!is.na(all$SalePrice),], aes(x=MiscFeature, y=SalePrice)) +
geom_bar(stat='summary', fun.y = "median", fill='blue') +
scale_y_continuous(breaks= seq(0, 800000, by=100000), labels = comma) +
geom_label(stat = "count", aes(label = ..count.., y = ..count..))
I am very confused about the geom_label arguments even though I searched the help list.What does the last line mean?Why I should also let
'y=stat(count)'
andrew310876:
..count..
This is the old syntax for referencing computed variables (computed by the specified stat function i.e. stat = "count"
), the new syntax would be stat(count)
Yes,I konw it.
I just do not konw what the line meaning
I want to add the number of each group on the plot
Are there any alternative ways?
I don't understand what you mean by this but you can map the label
aesthetic to whatever variable you want. To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
1 Like
system
Closed
November 30, 2020, 4:41pm
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.