Dear all,
I would like to ask for help. I run this code for my stock data with 617 stocks, but it has some problems with the output. In several cases, it doesn't extract the max day of the month. It only works well only when I filter by each stock. Do you know what is the problem with this? Thank you in advance.
This is my code.
price_month <-price%>% mutate(date = as.Date(date)) %>% group_by(year,mm) %>% filter(date == max(date))
The above code only works well when I filter each stock like that
price11<-filter(price1, stock == "PTC")
The class of each variable is in the picture below.