[R] How to show a specific value of a ggplot2
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Fri May 27 09:39:21 CEST 2022
Hello,
Neha, it's not the first time you post questions to R-Help, please,
please!, start your scripts by loading the packages needed.
I have never used package DALEX but for what I understand from its
documentation it helps to explore and explain models behavior. If your
profile plot was output by method plot.model_profile(), the workflow is
or seems to be
1. fit a model;
2. create an object of S3 class "model_profile" with functions explain()
and model_profile();
3. plot that object.
So to know what is the value of y for a given x, predict from the fitted
model, package DALEX and its plots have nothing to do with it.
If there's a predict method for the fitting function, then it should be
as simple as
newdata75 <- data.frame(x = 75)
y75 <- predict(fit, newdata = newdata75)
or something similar.
I have never used this package so I might be completely wrong.
Hope this helps,
Rui Barradas
Às 08:09 de 27/05/2022, Neha gupta escreveu:
> Thank you Rui, Avi
>
> I am using the plot(), in the Dalex package and it implements the ggplot.
>
> So I only used plot(mydata) and it displays the ggplot . If we need to
> adjust or make further changes in the plot, I think people use
>
> plot + .....
> I don't know if this group support the image pasting but my plot is
> showing like below. (bugs is a variable in my data whose values are
> displayed on y-axis and RFC is another variable in my dataset whose
> value is shown on the x-axis. I want to know exactly (not necessarily
> using the plot, a simple print function should also work for me) what is
> the value of 'bug' when the value of 'rfc' is 75.
>
> image.png
>
>
> On Fri, May 27, 2022 at 7:49 AM Rui Barradas <ruipbarradas using sapo.pt
> <mailto:ruipbarradas using sapo.pt>> wrote:
>
> Hello,
>
> If you cannot determine the exact value of y for given x, then isn't
> your problem how to determine an approximate value of y? Once you have
> it, it's easy to plot it.
>
> With newdata = data.frame(x = 75, y = ???),
>
>
> ggplot(mydata, mapping = aes(x, y)) +
> geom_point(color = "black") +
> geom_point(newdata, mapping = aes(x, y), color = "red") +
> xlim(0, 200)
>
>
> The question is how to find newdata$y, interpolation, other method?
>
> Hope this helps,
>
> Rui Barradas
>
> Às 00:40 de 27/05/2022, Neha gupta escreveu:
> > I have a ggplot2 which has x-values 0-200 and y values 0-10
> >
> > p=plot(mydata)
> > p+xlim(0, 200)
> >
> > I want to show what is the y value when we have 75 as x value.
> The graph
> > which is displayed has a broad range (like 0-50, 50-100 etc on x
> axis) and
> > cannot determine the exact value of y at the value of 75 on x-axis.
> >
> > Thank you
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help using r-project.org <mailto:R-help using r-project.org> mailing list
> -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list