课程: R Code Challenges: Data Science
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Comparing stock price and interest rates - R教程
课程: R Code Challenges: Data Science
Solution: Comparing stock price and interest rates
- [Instructor] In this challenge, I ask you to find the correlation between stock price and interest rates. You're supplied with two data sets, the Apple stock prices from June 6th, 2019 to the current day, and this is a data frame. You're also supplied with US interest rates from July, 1954 to the current day, so you can see that these two data sets somehow map together, but it's not a one-to-one correspondence. Somehow you'll need to join these two and then return the correlation. Let's take a look at how that can be done. Here's the code I wrote to solve this problem, and you may have done this a different way. What I've chosen to do is create a function called core stock, and you're going to give it the first date and the last date. That's part of the setup for the code of pad experiment. Line three loads in the files that you'll need. In line five and six, I've created a vector called first date and a second vector called last date. This is unnecessary as you can just put this…