I am looking to create a circle and then overlay a line segment from the origin to a given point on the circle (in this trial run, I chose to have the line segment end at (.25,.25)). For the research I am conducting, I need to be able to generate these line segments in multiple lengths and endpoints, so I am hoping for a code that lends itself to that. Here is what I have thus far. I have only recently started to learn R, so any advice will be well appreciated.
circle<- function(center=c(0,0),r,npoints=1000){
tt<-seq(0,2*pi,length.out=npoints)
xx<-center[1]+r*cos(tt)
yy<-center[2]+r*sin(tt)
return(data.frame(x=xx,y=yy))
}
circle1<-circle(c(0,0),.48)
k<-ggplot(circle1,aes(x,y))+geom_line(aes(0,0,.25,.25))
k