How do i add lines using a function to ggplot2? Something in a similar fashion to what i would do in R.
x <- 1:10 ; y <- 1:10
MakeStar <- function(point , numLine , r = 0.5){
for (i in 1:numLine) {
segments(point[1] , point[2] , point[1] + r * sin(i / (2 * pi)) , point[2] + r * cos(i / (2 * pi)) )
}
}
plot(y ~ x)
for (j in 1:10) {
MakeStar(c(x[j],y[j]) , j)
}
To clarify, I'm asking if there's an option in ggplot2 to make a calculation based on some points and then add lines to each of the points similar to the plot above.
Thanks!

