# How can I reproduce the results of sample\_tree() ?

**URL:** <https://igraph.discourse.group/t/how-can-i-reproduce-the-results-of-sample-tree/1368>\
**Category:** Usage\
**Tags:** R\
**Created:** [26 September 2022 18:35 UTC](https://igraph.discourse.group/t/how-can-i-reproduce-the-results-of-sample-tree/1368 "2022-09-26T18:35:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeesP](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@KeesP](https://igraph.discourse.group/u/KeesP)\
**Post date:** [26 September 2022 18:35 UTC](https://igraph.discourse.group/t/how-can-i-reproduce-the-results-of-sample-tree/1368/1 "2022-09-26T18:35:23Z")

</div>

At the beginning of mine igraph session I did run:

```auto
Sys.time()
set.seed <- 1L
g <- sample_tree(1e1, directed = TRUE)
V(g)[which(degree(g, mode="out")== 0)]

```

This gives:

```auto
[1] "2022-09-26 20:12:07 CEST"
+ 6/10 vertices, from bb5712c:
[1] 1 3 7 8 9 10

```

Then I tried the same code that produced something different:

```auto
[1] "2022-09-26 20:12:09 CEST"
+ 3/10 vertices, from bc890d8:
[1] 1 3 5

```

Apparently the `set.seed(1L)` command is not sufficient to guarantee the same results.

How should this be done?

---

<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:** [26 September 2022 19:16 UTC](https://igraph.discourse.group/t/how-can-i-reproduce-the-results-of-sample-tree/1368/2 "2022-09-26T19:16:45Z")

</div>

> [@KeesP](#):
>
> `set.seed <- 1L`

I believe this should be `set.seed(1L)` instead.

---

<div class="post-metadata">

**Author:** ![KeesP](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@KeesP](https://igraph.discourse.group/u/KeesP)\
**Post date:** [26 September 2022 20:11 UTC](https://igraph.discourse.group/t/how-can-i-reproduce-the-results-of-sample-tree/1368/3 "2022-09-26T20:11:11Z")

</div>

Indeed. Thanks.

`set.seed <- 1` assigns an integer to the name `set.seed`, rather then initializing the random procedure.
