Created
April 13, 2013 08:40
-
-
Save agstudy/5377621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## read data | |
ll <- readLines(textConnection('28/03/13 FACTURE CARTE DU 240313 PHOTOBOX SARTROUVILLE CARTE -30 | |
25/03/13 2EME TIERS SUR FACTURE DE 180 EUR DU 240113 CAROLL INTL PARI -60 | |
25/03/13 RETRAIT DAB 24/03/13 11H15 166936 BNP PARIBAS PARIS -200.50 | |
18/03/13 PRELEVEMENT TRESOR PUBLIC 94 IMPOT NUM 005002 ECH 18 -500')) | |
## convert data to a data.frame | |
dat <- do.call(rbind,strsplit(gsub('[ ]{2,}','|',ll),'\\|')) | |
## name columns | |
colnames(dat) <- c('date','category','desc','amount') | |
dat <- as.data.frame(dat) | |
## type variables | |
dat$date <- as.Date(dat$date,'%d/%m/%y') | |
dat$amount <- as.numeric(as.character(dat$amount)) | |
dat$desc <- as.character(dat$desc) | |
## you can aggegate per date for example | |
library(plyr) | |
dat.daily <- ddply(dat,.(date),summarise,amount = sum(amount)) | |
library(ggplot2) | |
ggplot(dat.daily)+ | |
geom_line(aes(x=date,y=amount)) | |
## you can compute amout per category | |
table(dat$amount,dat$category) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment