The order in the output correspond to the order of the input. I will patch the code so that it grabs the row names of the input (if exist). If you specify type="prob", it already labels the rows by the input row names.
> -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Dennis Duro > Sent: Tuesday, December 07, 2010 11:46 AM > To: r-help@r-project.org > Subject: [R] randomForest: How to append ID column along with > predictions > > 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 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > Notice: This e-mail message, together with any attachme...{{dropped:11}} ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.