How to formally write down mapping to a category with math notation? I'm writing a paper and would like to describe my approach with formulas too. However, I have a problem with writing down the following mapping step (just a tiny step of my algorithm).
Imagine, that I have a vector of numbers (they are computer port numbers):
80, 22, 22, 443, 80, 443, ... , 80

Now I map them to the "categories" like this:
1, 2, 2, 3, 1, 3, ..., 1

where 80 is first category found, so it will be always mapped to 1, 22 - second category found, so it will be always mapped to 2, and so on.
Another example with vector of usernames, I map
bob, alice, bob, carol, bob, bob

to 
1, 2, 1, 3, 1, 1

If you know R programming language, all I do is:
as.numeric(factor(v))

So now I want to describe it in the paper formally with something like:
"I have a dataset $D = \{c_1,c_2,...,c_n\}$, where each column is a vector of values:
$c_j = \{x_1,x_2,...,x_m\}$
now for each column $c_j$ I map it to
$c'_j = \{f_j(x_1),f_j(x_2),...,f_j(x_m)\}$, where $f_j(x)$ = ???"
so my question is what to write instead of ??? (Using words I can describe it as "mapping to category", but how to write it down using mathematical notation?)
 A: If you really want to intimidate your readers, do the following (for each column vector):


*

*Let $N$ be the number of items in the vector. Let $I = \{1, \dots, N\}$ be the index set of the objects in the vector. Let your vector be $(x_i)_{i \in I}$.

*Introduce a binary relation on $I$ by $i \sim j \iff x_i = x_j$. It is easy to prove that this is an equivalence relation.

*Let $\hat I$ be the quotient set $I / \sim$ and for each $i \in I$ let $\hat i \in \hat I$ denote its equivalence class under the relation $\sim$.

*Finally, create a new vector $(\hat i) _{i \in I}$ by putting on position $i$ its equivalence class $\hat i$. In your own notations, $f(x_i) = \hat i$.
This will make your readers collapse in awe and not understand anything, and your bosses humbly beg you to accept an increase of your salary (or order you shot for fearing that you would outsmart and next overthrow them).
A: 
Note: This answer is more a hint or an advice against formulas which are not essential for a proper understanding in a technical documentation. If your description is part of SW design specification or a technical user guide, it should be informative, precise and easy to read.

So, use formulas and technical terms the reader is familiar with and use them only if it is convenient for a proper understanding and a precise specification. In fact I think, that parts of your question act already perfectly valid as technical description. Maybe you need some more technical terms, in order to provide a proper documentation.

I suppose an accurate description of the data structure $D=\{c_1,c_2,\ldots,c_n\}$ already exists. So, we know what kind of data the columns $c_j$ may contain, we know about the specified maximum size of a column and the maximum number $n$ of columns in $D$.
If we describe a column $c_j$ in detail, it is convenient to denote it as $n$-tuple and not as set, since the ordering of elements is relevant. So, lets write
  \begin{align*}
c_j=(x_1,x_2,\ldots,x_n)
\end{align*}

Hint: In order to describe the mapping of the values of a vector to categories, which are in fact natural numbers you could use the familiar terms sequence numbers and FIFO and you could write

The elements $x_i$, which are e.g. port numbers or usernames are bijectively mapped to ascending sequence numbers starting from $1$ in FIFO manner. So, e.g. a vector $c_j$ of usernames is mapped to a vector $n_j$ of sequence numbers
\begin{align*}
c_j&=(bob,alice,bob,carol,bob,bob,\ldots)\\
n_j&=(1,2,1,3,1,1,\ldots)
\end{align*}

The explanation above together with your instructive example tells the reader formidably what he should know. So, I don't think, that formulas would help to improve this part of the documentation.
