How do you calculate cyclomatic complexity for R functions?
问题 Cyclomatic complexity measures how many possible branches can be taken through a function. Is there an existing function/tool to calculate it for R functions? If not, suggestions are appreciated for the best way to write one. A cheap start towards this would be to count up all the occurences of if , ifelse or switch within your function. To get a real answer though, you need to understand when branches start and end, which is much harder. Maybe some R parsing tools would get us started? 回答1: