[R] randomForest: How to append ID column along with predictions
Dennis Duro
dennis.duro at gmail.com
Tue Dec 7 17:45:59 CET 2010
Hi all,
When running a prediction using RF on another data, I get two columns
returned: row number(?) and predicted class. Is there a way of
appending the unique row value from an ID column in the dataframe to
the predictions instead of the row number? I'm assuming that the
returned results follow the data frame in that the first result
returned equals the first entry in the dataframe.
i.e., instead of a prediction output like this:
1, ants
2, ants
3, bees
4, ants
I'd like the first column to pull IDs from the dataframe associated
with each row (row number in parenthesis for illustration):
(1) 1130, ants
(2) 1130, ants
(3) 2139, bees
(4) 1130, ants
This is likely a simple procedure, but I haven't been able to get
anything to work. Any help would be appreciated!
Cheers,
Dennis
More information about the R-help
mailing list