twitterpig
V2EX  ›  问与答

R 语言包 ggplot2 中 set.seed 参数的疑问?

  •  
  •   twitterpig · May 25, 2017 · 2480 views
    This topic created in 3292 days ago, the information mentioned may be changed or developed.

    #load the ggplot2 library

    library(ggplot2)

    #set the seed so we can reproduce the results ##让样本可重复

    set.seed(1410)

    #create a variable that is the first 100 rows of the diamonds dataset

    dsmall <- diamonds[sample(nrow(diamonds), 100), ]

    set.seed 中的 1410,取这个数字有特殊的意义吗?是不是也可以取个随机数?

    我在网络上搜索到一些解释:

    1.设置随机数种子。

    2.就是设定随机数,保证下次生成的随机数和前面的一样

    小白不是特别明白,求教。谢谢

    marenight
        1
    marenight  
       May 25, 2017 via iPhone   ❤️ 1
    数字随便取,不过要想取得一致的随机结果,种子需要一样
    srlp
        2
    srlp  
       May 25, 2017
    随便。不 set.seed 也可以
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2281 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:46 · PVG 08:46 · LAX 17:46 · JFK 20:46
    ♥ Do have faith in what you're doing.