[R] ggplot barplot error
arun
smartpink111 at yahoo.com
Thu May 15 13:56:36 CEST 2014
Hi,
Please post in plain text. (lots of "*")
May be this helps:
Date <-
c("2014-04-01","2014-04-02","2014-04-03","2014-04-04","2014-04-07",
"2014-04-09","2014-04-10","2014-04-01","2014-04-02","2014-04-03",
"2014-04-04","2014-04-07","2014-04-09","2014-04-10")
Flows <- c(479.6,187.2, 148.6, 41.5, 123.5, 176.3, 68.3, 401.5,
-164.2, -195.5, 35.1, -224.0, -58.6, -138.9)
Category <- c("Equity", "Equity", "Equity", "Equity", "Equity", "Equity",
"Equity", "Debt", "Debt", "Debt", "Debt", "Debt",
"Debt", "Debt")
#data1 <- cbind(Date,Flows,Category) ##gives matrix output
data1 <- data.frame(Date, Flows, Category)
library(ggplot2)
dat1 <- subset(data1,Flows >= 0)
dat2 <- subset(data1,Flows < 0)
ggplot() +
geom_bar(data = dat1, aes(x=Date, y=Flows, fill=Category),stat = "identity", position="identity") +
geom_bar(data = dat2, aes(x=Date, y=Flows, fill=Category),stat = "identity", position="identity")
A.K.
Hi,
I am facing issue with ggplot plotting. I have given the data and the code
below. I have also attached the graph below.
Problem:
On date "*2014-04-07*", we have debt and equity flow, but it does not shows
equity flow. Ideally what I would like is the stack for debt/equity starts
from X axis.
*## Data*
*Date <-
c("2014-04-01","2014-04-02","2014-04-03","2014-04-04","2014-04-07",*
*
"2014-04-09","2014-04-10","2014-04-01","2014-04-02","2014-04-03",*
* "2014-04-04","2014-04-07","2014-04-09","2014-04-10")*
*Flows <- c(479.6,187.2, 148.6, 41.5, 123.5, 176.3, 68.3, 401.5,*
* -164.2, -195.5, 35.1, -224.0, -58.6, -138.9)*
*Category <- c("Equity", "Equity", "Equity", "Equity", "Equity", "Equity",*
* "Equity", "Debt", "Debt", "Debt", "Debt", "Debt",*
* "Debt", "Debt")*
*data <- cbind(Date,Flows,Category)*
*## GGplot*
*ggplot(data = fii.df, aes(x = Date, y = FII, fill = Category)) +
geom_bar(stat="identity") *
Thanks in advance.
Regards
Vikram Bahure
More information about the R-help
mailing list