library(pacman) p_load(ggplot2) p_load(plyr) df1 = read.table('./running.csv', header=F, sep=',') names(df1) <- c("dates", "running_balance") df1$running_balance = as.numeric(df1$running_balance) df1$dates = as.Date(df1$dates, "%Y-%m-%d") df1 <- df1[!duplicated(df1[c('dates')]),] df1$type <- rep('current',nrow(df1)) head(df1) #head(if(df$running_balance > 0, )) #df$sign <- ifelse(df$running_balance > 0, "green", "red") #df2 = read.table('./sw-running.csv', header=F, sep=',') #names(df2) <- c("dates", "running_balance") #df2$running_balance = as.numeric(df2$running_balance) #df2$dates = as.Date(df2$dates, "%d/%m/%Y") #df2 <- df2[!duplicated(df2[c('dates')]),] #df2$type <- rep('pension',nrow(df2)) #head(df2) #df <- rbind(df1,df2) #nrow(df) #head(df,n=100) pdf('cashALL.pdf', height = 8.3, width = 15) ggplot(df1, aes(dates, running_balance)) + geom_bar(position='stack', stat='identity', width=0.5) + theme_bw() + scale_x_date(minor_breaks=NULL,date_breaks = "1 day",limits = c(as.Date("2018-01-01"), as.Date("2018-12-01"))) #+ coord_flip() dev.off()