Im new in R programming, I want to plot multiple triangles in one chart. When I placed the ggplot command inside a for loop, it only resets the chart viewer.But I want to see all the plots in one plot simultaneously. Here's the code that I have been working on.
data<-read.csv("test.csv",sep=",",header=TRUE)
library("ggplot2")
for(i in 1:5){
D=data.frame(x=c(data$x1[i],data$x2[i],data$x3[i]),
y=c(data$y1[i],data$y2[i],data$y3[i]))
print(ggplot()+
(geom_polygon(data=D, mapping=aes(x=x,y=y),col="blue")))
}
I hope you can help me.Many thanks