Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205423

Error: Invalid input: date_trans works with objects of class Date only; in ggplot but I have already formatted date variable to Date format

$
0
0

Following is the code where I'm getting this error. Ab_Or_Bl_Med_Netbuy$date is already formatted to date format and Ab_Or_Bl_Med_Netbuy$0_508998_CO, Ab_Or_Bl_Med_Netbuy$1_508998_CO, Ab_Or_Bl_Med_Netbuy$508998all of these variables are in numeric format.

ggplot(Ab_Or_Bl_Med_Netbuy, aes(x=date)) +
geom_line(aes(y = Ab_Or_Bl_Med_Netbuy$`1_508998_CO`, color="AB_Median")) + 
geom_line(aes(y = Ab_Or_Bl_Med_Netbuy$`0_508998_CO`,"BL_Median")) +
geom_line(aes(y = Ab_Or_Bl_Med_Netbuy$`508998`,color="Cum_Dai_Ret"))+
scale_color_manual(values=c(AB_Median='#000000',BL_Median= '#FF0000', Cum_Dai_Ret='#00FF00')) +
theme_light()+ ggtitle("BSE_Scrip_508998") + 
theme(plot.title = element_text(hjust = 0.5)) +ylab("Cum_Net_Buy_Frac") + 
xlab("Date") + 
ylim(-50,50) +
scale_x_date(date_labels = "%Y")

If I run the above code without second geomline then code is working fine but the moment I put back the second geomline code again I'm getting the error "Error: Invalid input: date_trans works with objects of class Date only".


Viewing all articles
Browse latest Browse all 205423

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>