How to compute 90-th percentile of data with Inf values? I need to compute an effective diameter is 90-th percentile of the distribution of shortest path lengths of a graph.
My attempt is:
library(igraph)
set.seed(4)
g <- erdos.renyi.game(n=50, p.or.m=100, type="gnm", directed=TRUE, loops=FALSE)
sp <- as.vector(shortest.paths(g, algorithm = "dijkstra", mode="out"))
sp <- sp[!is.na(sp) & !is.infinite(sp)] # delete NaN and Inf
quantile(sp, 0.9)
# 7

In the sapmle data the Inf values were deleted.
Question. Is it suitable to delete Inf value for the q-th percentile calculation?

If you delete these values when looking at the quantiles then you are implicitly making an inference about the quantiles of the conditional distribution when the outcome is not infinity, instead of the marginal distribution of your data.  For this type of problem, you should consider what the Inf outcome means in your data and decide if you want to make an inference that is conditional on this outcome not occurring (using the conditional distribution), or an inference that allows for this outcome (using the marginal distribution).  That decision will require contextual judgment based on the meaning of the Inf outcome and the goal of your analysis.
