# Exporting determined degree values for certain nodes

**URL:** <https://igraph.discourse.group/t/exporting-determined-degree-values-for-certain-nodes/1215>\
**Category:** Usage\
**Tags:** R\
**Created:** [10 May 2022 12:51 UTC](https://igraph.discourse.group/t/exporting-determined-degree-values-for-certain-nodes/1215 "2022-05-10T12:51:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BryceFinch](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@BryceFinch](https://igraph.discourse.group/u/BryceFinch)\
**Post date:** [10 May 2022 12:51 UTC](https://igraph.discourse.group/t/exporting-determined-degree-values-for-certain-nodes/1215/1 "2022-05-10T12:51:58Z")

</div>

I’ve developed an edgelist and would like to return the degree values I receive when using the simple “degree” function to a format I can easily read such as .csv or .txt file.

My imagination would have it so in one column the nodes would be listed while the second column the degree values.

Is there any method that currently exists that allows me to do this?  
Thank you all for your time and help 🙂

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [10 May 2022 13:31 UTC](https://igraph.discourse.group/t/exporting-determined-degree-values-for-certain-nodes/1215/2 "2022-05-10T13:31:52Z")

</div>

I’m not too experienced with R, but this should work:

```auto
g <- sample_gnm(10, 20)

df <- data.frame(vertex=as_ids(V(g)), degree=degree(g))

```

Then you can export `df` using `write.csv`, e.g. `write.csv(df, 'myfile.csv', row.names=F)`.

Another way is to first save the degrees as a vertex attribute, then use `as_data_frame()`:

```auto
V(g)$degree <- degree(g)
df <- as_data_frame(g, what='vertices')

```
