课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

Random numbers

Random numbers

- [Instructor] At some point, you're going to need some random numbers. And R supplies at least three ways to do this. So let's take a look at R norm, R unif, and sample. For our example, let's assume that I need to draw three random names for three chickens, so the names must be unique. I'll need some chicken names, so I'll source them from make chick weight dot R, and there's a list of chicken names that I can use and select from 50 of them. Let's start off with R norm, which is random normal distribution, and the R norm command looks like R norm. And then I tell it how many numbers I'd like to generate and in this case, let's generate ten random numbers. And I hit command return, and there I have ten random numbers. R norm generates random numbers on a bell curve or a normal distribution. With R norm you can control the medium and you can control the standard deviation. Let's use that to generate some names. So I'll go chick names and from chick names I'll select random. I need…

内容