R seq_len(n)中出错:参数必须可强制为非负整数

R seq_len(n)中出错:参数必须可强制为非负整数,r,ggplot2,label,R,Ggplot2,Label,只是在R非常新-我错过了什么? 我觉得这和团体有关?以及as.因子(名称) 谢谢你指出错误和文件,这样我可以阅读和学习 克里斯 您有少于两个数据点的组,这些数据点将被删除。结果是max返回-Inf。试着不要刻面,看看会发生什么。哦,我想要刻面,但我明白你的意思-让我看看是否有办法不丢失数据点 library("ggplot") test <- tibble( name = c("TEAMA", "TEAMA", "

只是在R非常新-我错过了什么? 我觉得这和团体有关?以及as.因子(名称)

谢谢你指出错误和文件,这样我可以阅读和学习

克里斯


您有少于两个数据点的组,这些数据点将被删除。结果是
max
返回
-Inf
。试着不要刻面,看看会发生什么。哦,我想要刻面,但我明白你的意思-让我看看是否有办法不丢失数据点
library("ggplot")

test <- tibble(
  name = c("TEAMA", "TEAMA", "TEAMA", "TEAMB", "TEAMB"),
  percent = c(22.4, 18.8, 43.5, 25.5, 13.8),
  eff = c(.36, .62, .43, .16, .08),
  groups = factor(c("f","f","b","f","b"), levels = c("f","b")),
  col = c(1,2,1,1,1)
)
ggplot(data=test, aes(x=percent, y=eff, color=as.factor(name))) +
  facet_grid(groups ~ col) +  
  stat_density_2d()
Error in seq_len(n) : argument must be coercible to non-negative integer
In addition: Warning messages:
1: Computation failed in `stat_density2d()`:
missing value where TRUE/FALSE needed 
2: Computation failed in `stat_density2d()`:
missing value where TRUE/FALSE needed 
3: Computation failed in `stat_density2d()`:
missing value where TRUE/FALSE needed 
4: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
5: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
6: In max(f) : no non-missing arguments to max; returning -Inf