<p>Be careful that one-hot encoding using model.matrix may create really sparse datasets.</p>
<p>Another option is to actually use a recent packages that are purpose-built for highly dimensional / high volume data sets. They run their code using lower-level languages (C++ and/or Java) and in certain cases use parallelization for faster processing.</p>
<p>I'd recommend taking a look into these three:</p>
<p>ranger (uses C++ compiler) randomForestSRC (uses C++ compiler) h2o (Java compiler - needs Java version 8 or higher) Also, some additional reading here to give you more to go off on which package to choose: <a href="https://arxiv.org/pdf/1508.04409.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/1508.04409.pdf</a></p>
<p>Page 8 shows benchmarks showing the performance improvement of ranger against randomForest against growing data size - ranger is WAY faster due to linear growth in runtime rather than non-linear for randomForest for rising tree/sample/split/feature sizes.</p>
<p>Beyond that, using variable importance to reduce the feature size to those with the most information would improve model performance/accuracy.</p>
<p>Good Luck!</p>
Can not handle categorical predictors with more than 32 categories
<p>I'm trying to run random forest with a set of data that is 1664 (columns) x 208 (rows). My dependent variable is retention time (seconds), and my independent variables are 1664 different descriptors all the different chemical compounds. All of the descriptors give a value and are not categorical variables. I'm trying to perform a random forest for regression. However, when I try to run it using the following code:-</p>

<pre><code>urine.rf &lt;- randomForest(RT..seconds.~., data=urine, importance=TRUE)
</code></pre>

<p>I get the message:-</p>

<p>Error in randomForest.default(m, y, ...) : 
  Can not handle categorical predictors with more than 32 categories.</p>

<p>I read online that you can get around this by constructing some form of model.matrix. I'm completely new to R and haven't got the faintest clue about how to do this. I've tried formatting my cells in my csv file so that all the cells were numbers, but for some reason it still comes across as categorical predictors. How do I get around this?</p>

<pre><code>RT (seconds)    1_MW    2_AMW   3_Sv    4_Se    5_Sp    6_Ss    
46.58353    155.18  7.76    11.8    20.61   12.21   32.67   0.59
46.79514    145.29  5.01    14.76   28.37   16.11   21  0.51
48.18893    169.21  7.36    13.4    23.49   13.97   34.17   0.58
49.94328    169.21  7.36    13.4    23.49   13.97   34.17   0.58
50.81087    187.33  5.51    17.87   33.59   19.32   30.17   0.53
51.3834 104.2   4.96    10.39   20.67   11.41   16.5    0.49
51.51799    125.17  8.94    7.41    14.81   8.3 27.92   0.53
52.67208    117.13  7.81    8.2 15.73   8.45    29.33   0.55
52.79043    137.18  7.22    11.59   19.12   12.13   26.33   0.61
52.79046    161.23  6.2 13.71   26.27   14.7    33.5    0.53
</code></pre>

<p>This is what the database I'm using looks like. I want RT to be my Y variable, and everything else (1_MW and all the others after) to be my independent variables (there's 1664)</p>

<p>Thanks</p>