1D data classification
This is actually a 1-liner with the built-in split function:

ClassifiedrDataSplit &lt;- split(rData, rClass)


You can confirm this returns the same result as your original code:

identical(ClassifiedrData, ClassifiedrDataSplit)
# [1] TRUE


In addition to being a lot less code, this will result in sensible speedups for larger datasets. For instance, consider the performance with 10 million elements and 10 classes:

rData &lt;- sample(x = as.integer(c(1:1e7)), size = 1e7)
rClass &lt;- sample(x = c(1:10), size = 1e7, replace = TRUE)
system.time({i &lt;- 0
ClassifiedrData &lt;- CreateEmptyDictionary(names &lt;- sort(unique(rClass)))

for (a in rData) {
    i &lt;- i + 1
    #ClassifiedrData[[rClass[i]]] &lt;-  append(ClassifiedrData[[rClass[i]]], a)
    ClassifiedrData[[rClass[i]]][length(ClassifiedrData[[rClass[i]]])+1] &lt;- a
}})
#    user  system elapsed 
#   5.248   0.435   5.749 
system.time(split(rData, rClass))
#    user  system elapsed 
#   0.258   0.083   0.357 


The solution with split is about 10x faster.