pwerth
pwerth

Reputation: 210

Set rownames row number

I have a very large matrix M and I would like the name of each row of the matrix to be Person i, where i is the row number. I basically want the logical equivalent of the following:

names <- vector()
for(i in 1:numberofrows) {
    names[i] <- ("Person " , i)
}
rownames(M) <- names

I'm new to R so the above might not make complete syntactical sense but I'm just trying to convey the logic.

Upvotes: 0

Views: 925

Answers (1)

xb.
xb.

Reputation: 1677

rownames(M) <- paste("Person",seq(nrow(M)))

Upvotes: 5

Related Questions