Displaying 1 result from an estimated 1 matches for "logicalvar".
Did you mean:
localvar
2017 Aug 13
1
ggplot's aes_ doesn't work as expected for x=factor()
I'm learning how to use ggplot in a programming approach where I supply variable names on the fly. Using aes_ doesn't work as I expected when x = factor(x). Is this a bug or am I not understanding something?
# toy dataset
df <- data.frame(LogicalVar = c(FALSE, TRUE, FALSE, TRUE, FALSE, TRUE),
Var1 = c(0.01, 0.01, 1, 1, 30, 30),
pct1 = c(12, 88, 60, 40, 93, 7),
Var2 = c(2, 2, 4, 4, 8, 8),
pct2 = c(43, 57, 10, 90, 50, 50)
)
varnames <- names(df)
# using aes()-...