data$row_names <- row.names(data) # Apply row.names function data # Print updated data # x1 x2 row_names # 1 A e 1 # 2 B d 2