我正在使用以下代码创建一个带有 ggplot2 的饼图,其中包含两个彼此相邻的饼图:一个用于“MotT”的每个值。每个饼图需要如何为每个“模型”分配比例。这是我的代码:
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)
)
)
尝试运行 "df=sqldf("select..."
Error in sqliteExecStatement(con, statement, bind.data) :
RS-DBI driver: (error in statement: near "Values": syntax error)
当然 p 是空的。我明白了
Error: No layers in plot
如果我尝试调用它。
任何帮助将不胜感激!谢谢