I have multiple objects that I created which include data I need for each triangle. I now want to create triangles and export to csv, but I have so many datasets that I’d like to do this in a loop. Bonus points if I can also name each csv the same as the triangle name (for example below, LiabilityTriangleMonthly). My current code that works on a one-by-one basis is as follows:
Liability_Triangle_Monthly = as.triangle(LiabilityData_Monthly,
dev = "MaturityMonth",
origin = "AY",
value = "IncurredTotal")
LiabilityTriangleMonthly=as.matrix(Liability_Triangle_Monthly)
LiabilityTriangleMonthly[is.na(LiabilityTriangleMonthly)]<-0
write.csv(LiabilityTriangleMonthly,"//filepath/LiabilityTriangleMonthly.csv")
For reference, the names of 2 of my objects:
LiabilityData_Monthly
PhysDamData_Monthly
Tried to create a list to loop through… but very new to R and need a simpler version than what I’ve seen on this site already.
JustAskingQuestions is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.