Q:

How do I mark the coordinate of a point on x & y axis in R

An example will be like this:

The x, y coordinate of point (1, -1) are extended to the x, y axes. Right now, I am just adding 2 dotted lines y = 1 and x = -1 by function xline and yline from the package fields. However, this does not work when the point I want to mark is something like (0.5, -0.5). Then the corresponding values are not already included in the axis. In this case, the x axis should have label -1, 0, 0.5, 1, 2, 3 but I am missing 0.5 here. How do I fix it?
Edit:
For example, suppose I plotted the parabola y = (x - 0.5)^2 - 0.5
quadratic <- function (x) {
    return((x - 0.5)^2 - 0.5)
}
curve(quadratic, from = -1, to = 2)

How do I mark the coordinate of the vertex like the example in the picture?

A:

You can just set the x-component and y-components to 0 to get the two points, and play with the adj and pos parameters to text to place text in certain locations around the point if you want to label.
## Your setup
curve(-(x-1)^2-1, ylim=c(-5,0), xlim=c(-1, 3))
abline(h=0, v=0, lwd=2)
grid()

## Add a point
p <- c(1, -1)
points(t(p), pch=16)
text(t(p), "Vertex", adj=-1)

## At axes
ps <- diag(2)*p  # get points at axes
points(ps, col="red", pch=c("|", "-"), cex=1:2)
text(ps, col="black", labels=paste(diag(ps)), pos=c(1, 4))

