Hello community, I'm a college student currently taking up Rstudio as a pre-requisite course, so I am very new to R studio. I followed my lecturer's slide and entered the prompt but I would either get null in environment or conflicted packages under console when i try to run/knit. Please help as my lecturer isnt giving me any help and tells me it's in my spelling but I followed the prompt step by step and its killing me how it's not working.
I keep getting null in my environment when i try to get stocks for the prompt below.
library(tidyverse)
library(tidyquant)
stocks <- tq_get(c("NFLX" , "MCD"), get = "stock.prices", from = "2019-01-01")
Hi!
From what I’ve seen of the docs here:
the examples with the from
parameter also have the to
parameter representing the end date.
I would try
stocks <- tq_get(c("NFLX" , "MCD"), get = "stock.prices")
and/or
stocks <- tq_get(c("NFLX" , "MCD"), get = "stock.prices", from = "2019-01-01", to = "2020-01-01")
It is expected to see conflicts when loading the tidyverse and tidyquant packages. You're just being told that some functions have been overridden by functions with the same name from another package, for example, as.Date() would have used base::as.Date() but is now zoo::as.Date(). This is just a FYI, not an error.
stocks <-tq_get(c("NFLX", "MCD"), get = "stock.prices", from = "2019-01-10")
should work. What happens when you highlight just that line and press "Run Selected LIne(s)"?
Hello, it still shows Stock value = Null sadly
I tried both and the stock value is still null.
if I start a new R session and then do:
tidyquant::tq_get(c("NFLX", "MCD"), get = "stock.prices", from = "2019-01-10")
I get
Restarting R session...
> tidyquant::tq_get(c("NFLX", "MCD"), get = "stock.prices", from = "2019-01-10")
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
# A tibble: 2,876 × 8
symbol date open high low close volume adjusted
<chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 NFLX 2019-01-10 315. 325. 312. 325. 13472500 325.
2 NFLX 2019-01-11 331. 341. 329. 338. 19500400 338.
3 NFLX 2019-01-14 334. 335. 329. 333. 10499600 333.
4 NFLX 2019-01-15 350. 357. 347 355. 21181200 355.
5 NFLX 2019-01-16 354 359. 348. 351. 15385500 351.
6 NFLX 2019-01-17 350. 356. 346. 353. 18871200 353.
7 NFLX 2019-01-18 352. 353 337. 339. 26621000 339.
8 NFLX 2019-01-22 335. 337. 321. 325. 17941400 325.
9 NFLX 2019-01-23 328. 332. 319. 322. 13480100 322.
10 NFLX 2019-01-24 321. 332. 319 327. 11131600 327.
# ℹ 2,866 more rows
# ℹ Use `print(n = ...)` to see more rows
Show in New Window
Error in tq_get(c("NFLX", "MCD"), get = "stock.prices", from = "2019-01-10") :
could not find function "tq_get"
this is what it shows
I had never used {tidyquant} before today but
library(tidyverse)
library(tidyquant)
tidyquant::tq_get(c("NFLX", "MCD"), get = "stock.prices", from = "2019-01-10")
gives me the same results as @ mduvekot
I wonder if you are accidentally loading a .rdata
file into your workspace that is interfering with {tidyquant}.
Try deleting any .rda or .Rda files in your working directory and then go
Tools -> Global Options and, if needed change setting to what is shown in the image.
You need to install the tidyquant package AND load it.
install.packages("tidyquant")
library(tidyquant)
did this and the answer is still null
I did this and error message popped up to restart a few times and I just pressed ok a few times. Tidyquant is installed but the answer is still null
this is what it shows now
i even tried deleting and redownloading r yet nothing seems to work.
Try Resetting RStudio Desktop's State. It's a long shot but it does cure strange RStudio behaviours.
What happens if you do not use RStudio? Try running R from the command line. If it works, it does tell us that the problem is in RStudio.