r - 编织 RMarkdown 文件时发生错误
问题描述
try <- records %>%
group_by(cid) %>%
mutate(bef = week_num - lag(week_num), after = abs(week_num - lead(week_num))) %>%
mutate_at(c(6:7), ~replace(., is.na(.), 0)) %>%
filter(qty >= 5)
vec <- vector()
for(i in 1:nrow(try)) {
vec <- append(vec, try$after[i])
}
tableOfNumber <- base::table(vec)
totalchance <- sum(tableOfNumber[2:length(tableOfNumber)])
chanceplot <- tableOfNumber[2:length(tableOfNumber)]/totalchance
barplot(tableOfNumber[2:length(tableOfNumber)], main = "Num of weeks later after the 5th purchase", xlab = "Number of weeks", ylab = "Number of purchase",axes = FALSE)
axis(2,at=seq(0,1400,200))
barplot(chanceplot, main = "Probability of purchase after the 5th purchase", xlab = "Number of weeks", ylab = "Probability of purchase", axes = FALSE)
axis(2,at = seq(0,0.25,0.01))
我在代码块中很好地运行了这段代码,但是当我编织文件时,似乎有一个错误:只有字符串可以转换为符号。有人可以帮我吗
解决方案
推荐阅读
- php - Laravel - 如何有效地应用 Eloquent ORM 获取数据
- javascript - 有没有办法使用 Web Audio API 来编辑共振峰?
- java - Java 8 列表
- c++ - C++ 数组和内存位置
- c - exc 错误访问 C
- amazon-web-services - 删除后 Kubernetes 集群仍在运行
- java - 3sum 解决方案未通过测试用例(Java)
- java - 带有 Spring 和模块的六边形架构
- javascript - 使用 javascript 或 jquery 动态获取每个表列的所有值
- c# - Asp.net IDentity 2 Database First AspNetUserLogins' 没有定义键