I'm using the following code to create a pie chart with ggplot2, which contains two pie charts next to one another: one for each value of "MotT". Each pie chart need to how the proportions for each "Model". Here is my code:
library(ggplot2)
library(sqldf)
df <- data.frame("MorT" = c(1,2,1,2), "Model" = c(1,1,2,2),
"Values" = c(length(outOfTime1withIns[,1]),
length(outOfMem1withIns[,1]),
length(outOfTime1noIns[,1]),
length(outOfMem1noIns[,1])))
df=sqldf("select Values,
CASE WHEN MorT==1 THEN 'Insuficient Time'
WHEN MorT==2 THEN 'Insuficient Memory'
END MorT,
CASE WHEN Model==1 THEN '1) FSM1 with Insertion Dominance'
WHEN Model==2 THEN '2) FSM1 without Insertion Dominance'
END Model from df")
p = ggplot(data=df,
aes(x=factor(1),
y=Summary,
fill = factor(Model)
)
)
I get the following error after I try to run "df=sqldf("select..."
Error in sqliteExecStatement(con, statement, bind.data) :
RS-DBI driver: (error in statement: near "Values": syntax error)
And of course p is empty. I get
Error: No layers in plot
If I try to call it.
Any help will be very much appreciated!Thanks