ea9
ea9

Reputation: 21

set row names of dataset to be equal to another variable

data.frame example:

dataframe

Hi guys, I need to set row names of this dataset to be equal to the polling id station variable. Then I have to use row name indexing to report the name of the polling station with psid 089/081.

I'm new to r, all help is highly appreciated.

Upvotes: 1

Views: 206

Answers (2)

Seymour
Seymour

Reputation: 3284

very simple.

row.names(yourdf) <- yourdf$psid

Upvotes: 2

drmariod
drmariod

Reputation: 11782

what about rownames(df) <- as.character(df$psid)?

Upvotes: 2

Related Questions