0

So i currently have a dataframe in R where:

      degree

54     0.65
43     0.76
31     0.67

and by executing:

df[1]

it prints out the first row:

54       0.65

I'm trying to assign a column name to the first column, where i get:

vertex     degree

  54        0.65
  43        0.76
  31        0.67

So i can query the dataframe column separately:

df$vertex
df$degree

Is there any possible ways i could do this?

0

1 Answer 1

0

We can use rownames_to_column

library(tidyverse)
rownames_to_column(df1, 'vertex')

Or with base R

data.frame(df1, vertex = row.names(df1))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.