Is it possible to calculate median value and interquatile range for a set of numbers containing a range or inequalities? I am trying to make simple median and IQR calculations that involve numbers (in  percentages) appearing in a range and inequalities in addition to whole numbers. My sample dataset looks like this:
5, 10, < 1, 10 - 20, 25, > 90
Any suggestions on how I can perform these two calculations on such a dataset?
 A: In this case you can make a non-parametric estimate, although without important things like confidence intervals. You have a combination of left-censored (<1), right-censored (>90) and interval-censored (10-20) values.
Although you might not think of what you have as a survival problem, a survival function $S(t)$ is just 1 minus the corresponding (cumulative) distribution function $F(t)$ (i.e., $S(t)=1-F(t)$), so the median of $F(t)$ is the value corresponding to a "survival" fraction of 0.5, the first quartile that for a survival fraction of 0.75, etc. So you can use a survival modeling method designed to handle arbitrarily censored data to get estimates of quantiles.
The R icenReg package can calculate the Turnbull nonparametric maximum-likelihood estimate of a survival curve based on such data (a generalization of the Kaplan-Meier method for interval-censored data). That should be more generally useful than a method that requires you to pre-rank the exact and interval values.
To get a single non-parametric survival curve this way, provide a 2-column matrix with the lower and upper limits for each data point. For a known data point, those two values are identical. With your example percentage data (lower limit, 0; upper limit, 100):
library(icenReg)
datMat <- matrix(c(0,1,5,5,10,10,10,20,25,25,90,100),ncol=2,byrow=TRUE)
datMat
##     [,1] [,2]
## [1,]    0    1
## [2,]    5    5
## [3,]   10   10
## [4,]   10   20
## [5,]   25   25
## [6,]   90  100
icTest<- ic_np(datMat)
plot(icTest,bty="n")


I didn't change the default axis labels, so your values correspond to "time" here. $S(t)$ is the survival function for your data, although the boxes might look strange. The package vignette explains:

Looking at the plots, we can see a unique feature about the NPMLE for interval censored data. That is, there are two lines used to represent the survival curve. This is because with interval censored data, the NPMLE is not always unique; any curve that lies between the two lines has the same likelihood.

Based on the plot, you would accept the range of 10-20, corresponding to $S(t) = 0.5$, as including the median. The IQR would be 5 - 25 (corresponding to $S(t) = 0.75, S(t) = 0.25$).
If you have a reasonable parametric form for your data you can do much more with this type of modeling, as Frank Harrell suggests in his answer.
A: If you can order the levels of the observations, you can determine the median, and the 1st quartile and 3rd quartile.

*

*In your sample data, the observations could be ordered, with the exception that you have to decide if "10 - 20" is greater then "10", or if they would have the same rank when ranked.


*IRQ itself, as the difference between the 1st and 3rd quartile, wouldn't necessarily make sense.


*There are different methods to determine the value of quantiles.  For example, R has 9 options ( www.rdocumentation.org/packages/stats/versions/3.6.2/topics/quantile ).  Some are more appropriate for non-continuous data.


*With discontinuous data, you may get answers that are e.g. "Between 'good' and 'very good'.  In your sample data, the median would be between "10" and "10 - 20", assuming those are two different when ranked.


*The following can be run in R (or at e.g. rdrr.io/snippets/ ).  This assumes that "10 - 20" is greater than "10".  And uses R quantile type 1, which will not return answers that straddle two levels.
.
Observed = c("5", "10", "< 1", "10 - 20", "25", "> 90")

Obs.factor = factor(Observed,
                    ordered = TRUE,
                    levels = c("< 1", "5", "10","10 - 20", "25", "> 90") )

quantile (Obs.factor, type=1, probs=0.50)

quantile (Obs.factor, type=1, probs=0.25)

quantile (Obs.factor, type=1, probs=0.75)

A: If you only had "< 1" occuring you could compute the median.  In general you can't estimate what you want unless you assume a smooth parametric distribution and explicitly handle left, right, and interval censoring in computing the likelihood function so that you can get maximum likelihood estimates of the parameters of that distribution.  Then you compute the mean and quantiles which are functions of those underlying parameters.  It's pretty involved.
