Updated: I have categorical data (all binary) and want to make a barplot where all of the variables can be represented so it's easier to see which has the greatest effect on a dependent variable. So, for example, I have this:
df<- data.frame(
DV=c(0,0,1),
V1=c(0,0,0),
V2=c(0,0,1),
V3=c(0,1,0))
Here is what I've tried:
library(reshape2)
s<-as.data.frame(prop.table(ftable(df[c('DV', 'V1', 'V2', 'V3')])))
mdfr <- melt(s, id = "DV", measure="V1", "V2", "V3")
library(scales)
#And once that works I'd plot it this way
(r <- ggplot(mdfr, aes(position, value, fill = variable)) +
geom_bar(position = "fill", stat = "identity")) +
scale_y_continuous(labels = percent)
Creating s works fine, but what I need is the frequency to be the value in mdfr, and instead its the value of the categorical variables. Can anyone help figure out how to do this the correct way?
Thanks in advance!