Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # R Lab
- # 18/4/2012
- # Sean Allred
- path <- "~/cs/R/t/test2.txt"
- data <- read.table(path)
- types <- unique(data[[2]])
- months <- unique(data[[3]])
- mat <- matrix(nrow=length(months),ncol=length(types))
- colnames(mat) = months
- rownames(mat) = types
- for (month in 1:length(months)) {
- for (type in 1:length(types)) {
- mat[month, type] <- sum(subset(data, V3 == months[month] & V2 == types[type])[1])
- }
- }
- barplot(mat, beside=TRUE, legend.text=TRUE, xlab="Months", ylab="Money Spent (USD)", main="Spending")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement