You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
d%>%
ggplot()+
geom_point(aes_string(y = y, x = x ))
}
-------------------------------------------------------- Running the code --------------------------------------------------------
plot(y('AAPL', '^BVSP', '2000-01-01', '2024-01-01'))
This code just take a stock price (from yahoo finance) and a benchmark (ibovespa) and plot its correlation.
The problem is that when i try running the code is doesnt recognize the '^' and return the error:
Hi everyone.
I'm a beginner at coding in R and this is my first question here.
I'm working in the code above:
------------------------------------------------------------ Code ---------------------------------------------------------------------
require(tidyverse)
require(tidyfinance)
y <- function(y, x, start_date, end_date) {
d <- as_tibble(download_data(type = 'stock_prices', start_date = start_date, end_date = end_date,
symbols = c(y, x))%>%group_by(symbol)%>%mutate(return = adjusted_close / lag(adjusted_close) - 1)%>%
select(symbol, date, return)%>%pivot_wider(names_from = symbol, values_from = return)%>%drop_na())
d%>%
ggplot()+
geom_point(aes_string(y = y, x = x ))
}
-------------------------------------------------------- Running the code --------------------------------------------------------
plot(y('AAPL', '^BVSP', '2000-01-01', '2024-01-01'))
This code just take a stock price (from yahoo finance) and a benchmark (ibovespa) and plot its correlation.
The problem is that when i try running the code is doesnt recognize the '^' and return the error:
Error in parse(text = x, keep.source = FALSE) :
:1:1: '^' inesperado
1: ^
^
Is there any way to 'force' R to recognize this character or i need to remove it from the columns' name?
Thank you!
The text was updated successfully, but these errors were encountered: