how to set the first column as row names in r code example Example: how to set the first column as row names in r df2 <- df[,-1] rownames(df2) <- df[,1]