Error in select(., "symbol", "date", "adjusted") : unused arguments ("symbol", "date", "adjusted")

QUICK Help im trying to knit and am getting stuck on this problem

this is my code STOCK1<-c("BAC","NEU","ATVI") %>%
   tq_get(get = "stock.prices", from = "2000-01-01")%>%
   select(symbol, date, adjusted)

and this is the error

Error in select(., "symbol", "date", "adjusted") : 
  unused arguments ("symbol", "date", "adjusted")

What packages are you using and what order are you loading them in? That's not the error I would expect to see if you are trying to use dplyr::select and the columns you entered don't exist.

What is your output from

c("BAC", "NEU", "ATVI") %>%
  tq_get(get = "stock.prices", from = "2000-01-01") %>%
  head()
1 Like

As @dvetsch75 suggests, the select() function you are using doesn't seem to come from dplyr as it is intended, so to avoid any possible name clash use the fully qualified function name instead. Then, provided your packages are up to date, you should see this outcome (tested on RStudio Cloud, R 4.2)

library(dplyr)
library(tidyquant)

c("BAC","NEU","ATVI") %>%
    tq_get(get = "stock.prices", from = "2000-01-01") %>%
    dplyr::select(symbol, date, adjusted)
#> # A tibble: 16,950 × 3
#>    symbol date       adjusted
#>    <chr>  <date>        <dbl>
#>  1 BAC    2000-01-03     13.6
#>  2 BAC    2000-01-04     12.8
#>  3 BAC    2000-01-05     12.9
#>  4 BAC    2000-01-06     14.1
#>  5 BAC    2000-01-07     13.7
#>  6 BAC    2000-01-10     13.2
#>  7 BAC    2000-01-11     12.9
#>  8 BAC    2000-01-12     13.1
#>  9 BAC    2000-01-13     13.4
#> 10 BAC    2000-01-14     14.2
#> # … with 16,940 more rows

Created on 2022-06-16 by the reprex package (v2.0.1)

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.