# How to select the best variables by RandomForest in R?

I have a table of mRNA levels of my target gene and it's transcription factors in many different condition. What I want to do is to select the most important conditions and most important transcriptional factors. I used glm in R but I am stuck at the point that I can't extract the important data from it now. Could anybody help me please? I would like to use also Lasso, Elastic Net and Random Forest.

I've tried this:

data <- read.table("table.txt",header=T)
genenames=colnames(data)
attach(data_test)
f1=as.formula(paste(genenames[5],"~",genenames[1]))
glm(f1)
glm.linear <- glm(f1)
glm.linear

V1  V2  V3      V4    V5
1   3.85  3.85  9.41  4.31  9.01
2   3.98  4.01  8.50  3.95  7.35
3   3.98  3.98  8.17  4.07  8.58
4   3.61  4.10  7.94  3.88  4.59
5   3.74  3.95  9.55  4.08  7.79
7   3.78  3.98  7.72  3.91  4.73
8   3.76  4.05  7.60  3.71  4.49
9   3.75  4.08  7.71  3.76  4.73
10  3.81  4.19  8.03  3.75  4.53

-

## migrated from stackoverflow.comJan 7 '13 at 19:04

This question came from our site for professional and enthusiast programmers.

Show us some code of what you tried –  Ivan Ferić Jan 6 '13 at 14:37
Try str(glm.linear) , than you can access to all attributes using $, something like glm.linear$coefficients.. –  agstudy Jan 6 '13 at 15:26
something like doesn´t work.. could you please specificate it? I am R-beginner –  tutu Jan 6 '13 at 17:53
Could you post your data or a sample of it? As @agstudy said, str should give you all the components of glm.linear and then you can choose which one you want to look at. Or, if you are using RStudio, type glm.linear\$ and then press TAB and you may choose from the options there. Have a look at summary(glm.linear) as well. If you post sample data someone might be able to help you out more. –  MadScone Jan 7 '13 at 9:44
Feature selection is very hard and there is no silver-bullet function to do this. You really should go through some R course (say this), then browse feature-selection tag here and finally come back with more specific questions. –  mbq Jan 8 '13 at 7:51