V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
twitterpig
V2EX  ›  问与答

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

  •  
  •   twitterpig · 2017-05-25 13:52:30 +08:00 · 1648 次点击
    这是一个创建于 2525 天前的主题,其中的信息可能已经有所发展或是发生改变。

    #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  
       2017-05-25 14:15:38 +08:00 via iPhone   ❤️ 1
    数字随便取,不过要想取得一致的随机结果,种子需要一样
    srlp
        2
    srlp  
       2017-05-25 17:44:21 +08:00
    随便。不 set.seed 也可以
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3335 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 12:27 · PVG 20:27 · LAX 05:27 · JFK 08:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.