This has been answered in the comments, but to make it clearer that there is an answer, here's a small example:
First, some sample data:
(df <- data.frame(A = 1:2, B = 3:4, row.names = c("row1", "row2")))
# A B
# row1 1 3
# row2 2 4
The suggestion from the comments. Note that the original row.names
is still part of the data.
cbind(rn = rownames(df), df)
# rn A B
# row1 row1 1 3
# row2 row2 2 4
You can get rid of that by setting row.names = NULL
in the cbind
step. Since you are cbind
ing data.frames
, you could also pass other arguments to data.frame
if necessary (such as stringsAsFactors = FALSE
if you didn't want the "rn" column to be a factor
).
cbind(rn = rownames(df), df, row.names = NULL)
# rn A B
# 1 row1 1 3
# 2 row2 2 4
cbind(rownames(df), df)
? – GreatgranduncleWeka
? There is very little that can be done in Weka that cannot already be done in R without the need for the intermittent step – AcimaWEKA
. As you might see from my question I am not so familiar with R but have been usingWEKA
for quite a while. So nevertheless I will probably stay with it. But I will have a look on the machine learning functions in R. – Laylalayman