R-空间和'故障/';在变量和列名中
在我的excel文档中,我使用的列是“通信模式”,在该列中,有使用空格、“面对面”或斜杠“IM/Chat”的条目 它们不断抛出错误:R-空间和'故障/';在变量和列名中,r,excel,ggplot2,rstudio,R,Excel,Ggplot2,Rstudio,在我的excel文档中,我使用的列是“通信模式”,在该列中,有使用空格、“面对面”或斜杠“IM/Chat”的条目 它们不断抛出错误: eval(expr、envir、enclose)中出错:未找到对象“in.Person” IM/聊天也一样 我尝试使用In.Person或IM.Chat,但会出现错误。代码是: png(filename="Number of Interactions by Communication Mode.png") person <- subset(desktra
- eval(expr、envir、enclose)中出错:未找到对象“in.Person”
- IM/聊天也一样
png(filename="Number of Interactions by Communication Mode.png")
person <- subset(desktracker, Mode.of.Communication="")
ByChat <- ggplot(subset(desktracker, IM.Chat!=""), aes(x=IM.Chat)) +
geom_bar() +
theme_bw() +
ylab("Number of Interactions") +
xlab("By Chat") +
theme(axis.title.y = element_text(color = "red"))
ByPerson <- ggplot(subset(person, In.Person =""), aes(x=In.Person)) +
geom_bar() +
theme_bw()+
ylab("Number of Interactions") +
xlab("In Person")
grid.arrange(ByChat, ByPerson, ByPhone, main="Number of Interactions by Communication Mode
for Reference 2016")
dev.off()
png(filename=“按通信模式划分的交互次数.png”)
person我看不到您的变量名,但我建议如果您有标题,请更正数据框的列名:
colnames(desktracker) <- gsub(" |/", '.', colnames(desktracker))
如果对desktracker的内容一无所知,这是不可能回答的。请记住,如果要避免这些问题,数据框中变量的名称不应包含空格或点以外的特殊字符。语法上无效的变量名称,例如带有空格或特殊符号的变量名称,可以通过反勾“`”在ggplot2中使用。
colnames(desktracker) <- gsub(" |/", '.', colnames(desktracker))
setwd("Z:/DesktrackR/Ref_Semester")
file = "Desk_Tracker_flat_8-17-15_through_5-9-16.csv"
desktracker <- read.csv(file, sep=",", headers = TRUE)