我正在可视化 cricinfo 中的一些板球数据。我想重点介绍一些满足某些条件的播放器,但它总是使R studio崩溃。
#### Libraries ####
library(cricketdata)
library(dplyr)
library(ggrepel)
library(ggplot2)
### Fetching Data ####
menODI <- fetch_cricinfo("ODI", "Men", "Batting", type="career")
#### Creation of New Stat for Batsmen Ranking ####
menODI2 <- menODI %>%
mutate(Stat2 = 1- Average + Hundreds+Fifties/2)
#### Plot ####
menODI2 %>%
ggplot(aes(Innings, Stat2)) +
geom_point()+
geom_text_repel( col="forestgreen",aes(label=ifelse(Average>50 & Runs > 5000,as.character(Player),'')),
hjust=1.5,vjust=2.6, size=3)+
ggtitle("Average >50 + Runs > 5000")
R Studio尝试生成图,但是在没有给出任何原因的情况下崩溃。需要重新启动。
答案 0 :(得分:1)
我认为这是缓冲区溢出,在Windows平台上观察到,这是一个问题。
在线程中给出了更可靠的代表:
# test for bug in ggrepel/ggplot2
library(ggplot2)
library(ggrepel)
# sometimes works, usually R crashes
n = 1000L
my.data <- data.frame(x = runif(n), y = runif(n),
my.label = c(rep("", n/100 - 1), "abcd"))
# ggplot(my.data, aes(x, y, label = my.label)) +
# geom_label()
ggplot(my.data, aes(x, y, label = my.label)) +
geom_label_repel()
# never works, R crashes
n = 10000L
my.data <- data.frame(x = runif(n), y = runif(n),
my.label = c(rep("", n/1000 - 1), "abcd"))
# ggplot(my.data, aes(x, y, label = my.label)) +
# geom_label()
ggplot(my.data, aes(x, y, label = my.label)) +
geom_label_repel()