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