课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

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

askYesNo

askYesNo

- [Instructor] With R version 3.5, a new function has been added called Ask Yes-No. And it's useful let's take a look at it. First of all you want to check to make sure you have R version 3.5. And the way to do that is to type in "R.verson". That produces a string of information, most important, the second from the bottom, which is "version.string". And that tells me that I have R version 3.5.0. So I do have Ask Yes-No. If you don't have version 3.5, it's probably time to upgrade and you and you can do that at the R Project webpage. So let's take a look at Ask Yes-No. It's simple. Ask, yes, no, and you give it a prompt. And so I'm gonna say, "do you like carrots?" and I hit return, and it says, "oh, do you like carrots?" Well, yes, I do like carrots. So I type in a Y, and then I hit return. And it returns True. Now let's step through the options here. Ask Yes-No, and I ask myself again, "do you like carrots?" and I say, "no, I don't." It returns false. Now one more time. Ask Yes-No…

内容