Im trying to group bars in R to have them based on two variables, type
(Tax, income and VAT) and group
(A and B).
I succeeded to group based on the type, however when I´m trying to group it seem not to work.
plot <- ggplot(data=df, aes(x=Person, y=Amount, fill=FIAT ))+
geom_bar(aes(), stat="identity", position="fill")+
facet_grid(~type, scales="free_x")
The outcome I receive is this:
The wanted outcome should look something like this, with group in the bottom:
The output from dput:
dput(head(df.new))
structure(list(Person = c("Jon", "Bill", "Maria", "Ben", "Tina",
"lisa"), Amount = c(23, 41, 32, 58, 26, 54), type = c("Tax",
"Tax", "VAT", "Income", "Tax", "Income"), group = c("A", "B",
"B", "A", "B", "A"), FIAT = c("BTC", "GBP", "BTC", "EURO", "USD",
"USD")), row.names = c(NA, 6L), class = "data.frame")