Error: Can't subset columns that don't exist for date

Hey guys. I am having issue with the following.

> ## Import your assigned stocks
> 
> stocksassigned<-c("TSLA","GME","MKT") %>%
+   tq_get(get = "stock.prices", from = "2000-01-01") %>%
+   select(symbol, date, adjusted) 

when i run the code I get the following:

Error: Can't subset columns that don't exist.
x Column date doesn't exist.
Run rlang::last_error() to see where the error occurred.

1 Like

The code you are showing works just fine, maybe you forgot to load the libraries? Try restating your R session and run your code again, including the library calls.

library(dplyr)
library(tidyquant)

(stocksassigned <- c("TSLA","GME","MKT") %>%
    tq_get(get = "stock.prices", from = "2000-01-01") %>%
    select(symbol, date, adjusted))
#> # A tibble: 11,979 × 3
#>    symbol date       adjusted
#>    <chr>  <date>        <dbl>
#>  1 TSLA   2010-06-29     4.78
#>  2 TSLA   2010-06-30     4.77
#>  3 TSLA   2010-07-01     4.39
#>  4 TSLA   2010-07-02     3.84
#>  5 TSLA   2010-07-06     3.22
#>  6 TSLA   2010-07-07     3.16
#>  7 TSLA   2010-07-08     3.49
#>  8 TSLA   2010-07-09     3.48
#>  9 TSLA   2010-07-12     3.41
#> 10 TSLA   2010-07-13     3.63
#> # … with 11,969 more rows

Created on 2022-05-31 by the reprex package (v2.0.1)

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.

Hii. Thank you a lot for your help. It is still not working despite rechecking my libraries.

so what columns are available for you ?

library(dplyr)
library(tidyquant)

whatgot <- (c("TSLA","GME","MKT") %>%
    tq_get(get = "stock.prices", from = "2000-01-01"))

names(whatgot)
1 Like

yes I'm having the same issue, doesn't seem to be issue with the code, as it seems to be correct. there must be something else

Error: Can't subset columns that don't exist.
x Column DATE doesn't exist.

R is case sensitive so if date is present its an error to select DATE which has capitalisation.

Did you manage to solve this issue? im having the same issue with my assignment

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.