ERROR while rich displaying an object: Error: Continuous value supplied to discrete scale

目录

ERROR while rich displaying an object: Error: Continuous value supplied to discrete scale

问题:

解决

完整错误:

#参考示例mtcars


问题:

Pre0 <-rms::Predict(fit,Hb,fun=exp,type="predictions",ref.zero=TRUE,conf.int = 0.95,digits=2);
##其中fun是转化函数
ggplot(Pre0)
View(Pre0)ggplot()+geom_line(data=Pre0,aes(Hb,yhat,colour=gender),alpha=0.7)+scale_color_nejm()+ ##采用ggsci包中英格兰调色,也可以其他geom_ribbon(data=Pre0,aes(Hb, ymin=lower,ymax=upper,fill=gender),alpha=0.1)+scale_fill_nejm()+geom_hline(yintercept=1,linetype=2,size=0.75)

解决

as.factor把sex变量转化为因子即可;

Pre0 <-rms::Predict(fit,Hb,fun=exp,type="predictions",ref.zero=TRUE,conf.int = 0.95,digits=2);
##其中fun是转化函数
ggplot(Pre0)
View(Pre0)ggplot()+geom_line(data=Pre0,aes(age,yhat,colour=as.factor(sex)),alpha=0.7)+scale_color_nejm()+ ##采用ggsci包中英格兰调色,也可以其他geom_ribbon(data=Pre0,aes(age, ymin=lower,ymax=upper,fill=as.factor(sex)),alpha=0.1)+scale_fill_nejm()+geom_hline(yintercept=1,linetype=2,size=0.75)

完整错误:

ERROR while rich displaying an object: Error: Continuous value supplied to discrete scaleTraceback:
1. FUN(X[[i]], ...)
2. tryCatch(withCallingHandlers({.     if (!mime %in% names(repr::mime2repr)) .         stop("No repr_* for mimetype ", mime, " in repr::mime2repr").     rpr <- repr::mime2repr[[mime]](obj).     if (is.null(rpr)) .         return(NULL).     prepare_content(is.raw(rpr), rpr). }, error = error_handler), error = outer_handler)
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. doTryCatch(return(expr), name, parentenv, handler)
6. withCallingHandlers({.     if (!mime %in% names(repr::mime2repr)) .         stop("No repr_* for mimetype ", mime, " in repr::mime2repr").     rpr <- repr::mime2repr[[mime]](obj).     if (is.null(rpr)) .         return(NULL).     prepare_content(is.raw(rpr), rpr). }, error = error_handler)
7. repr::mime2repr[[mime]](obj)
8. repr_text.default(obj)
9. paste(capture.output(print(obj)), collapse = "\n")
10. capture.output(print(obj))
11. withVisible(...elt(i))
12. print(obj)
13. print.ggplot(obj)
14. ggplot_build(x)
15. ggplot_build.ggplot(x)
16. lapply(data, scales_train_df, scales = npscales)
17. FUN(X[[i]], ...)
18. lapply(scales$scales, function(scale) scale$train_df(df = df))
19. FUN(X[[i]], ...)
20. scale$train_df(df = df)
21. f(..., self = self)
22. self$train(df[[aesthetic]])
23. f(..., self = self)
24. self$range$train(x, drop = self$drop, na.rm = !self$na.translate)
25. f(..., self = self)
26. scales::train_discrete(x, self$range, drop = drop, na.rm = na.rm)
27. stop("Continuous value supplied to discrete scale", call. = FALSE)

#参考示例mtcars

ggplot(mtcars, aes(x=wt, y=mpg, color=as.factor(cyl), shape=as.factor(cyl))) +geom_point() + geom_smooth(method=lm, se=FALSE, fullrange=TRUE)+scale_shape_manual(values=c(3, 16, 17))+ scale_color_manual(values=c('#999999','#E69F00', '#56B4E9'))+theme(legend.position="top")

参考:"Error: Continuous value supplied to discrete scale" in default data set example mtcars and ggplot2

参考: R

参考:ggplot2

ERROR while rich displaying an object: Error: Continuous value supplied to discrete scale相关推荐

  1. 解决:Error: Continuous value supplied to discrete scale

    解决:Error: Continuous value supplied to discrete scale 目录 解决:Error: Continuous value supplied to disc ...

  2. R:使用ggplot2画散点图时出现错误: Continuous value supplied to discrete scale

    找了半天没找到,最后发现原因在于把shape=3放在了aes()里,把shape=3移出aes就没事了. 继续查原因,发现aes()里shape只能赋值给分组变量.整体使用某种shape,即设置sha ...

  3. Cannot get a connection, pool error Timeout waiting for idle object (获取不到数据库连接)...

    今天项目中遇到一个问题,一个定时器一段时间就会报错,一段时间又正常,错误如下: Caused by: org.hibernate.exception.GenericJDBCException: Can ...

  4. Android studio报Error:Expected NDK STL shared object file at libgnustl_shared.so

    错误详细描述 Error:Expected NDK STL shared object file at D:\sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\ ...

  5. vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in created hook: “TypeError: Object(...) is not a func

    前几天一个月薪35k的兄弟,给我推了一个人工智能学习网站,看了一段时间挺有意思的.包括语音识别.机器翻译等从基础到实战都有,很详细,分享给大家. 从后端拿取数据渲染到表格数据.结果明明写的没错,但是却 ...

  6. ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [Batch update retur

    遇到进行saveOrUpdate的时候新增数据hibernate报错 控制台报错信息: 21:48:09.282 [http-nio-8080-exec-2] ERROR org.hibernate. ...

  7. error:03000086:digital envelope routines::initialization error 问题解决

    问题描述 问题背景 更换新机器的时候下载使用了最新版的nodejs,部署老项目的时候启动报错了 错误描述 跑了一下ruoyi的项目试试,就直接给报了 Error: error:0308010C:dig ...

  8. Conversion error:Jekyll::Converters::Scss encountered an error while converting css/main.scss

    错误描述:Conversion error: Jekyll::Converters::Scss encountered an error while converting 'css/main.scss ...

  9. localhost: Error: JAVA_HOME is not set. [Hadoop] Error: JAVA_HOME is not set

    localhost: Error: JAVA_HOME is not set. 在namenode启动脚本%Hadoop_HOME%/bin/start-dfs.sh的时候发现datanode报错: ...

最新文章

  1. Visual Studio 快捷键 转载
  2. JavaScript 同时建立多个websocket连接
  3. 【数字信号处理】数字信号处理简介 ( 抽样定理 | 多抽样率 )
  4. iOS仿抖音节拍界面、Swift,MVVM架构完整项目、日历demo、滚动切换分类等源码
  5. 释疑の采购订单的批量修改
  6. Win7删除休眠文件
  7. 深入浅出InfoPath——动态获取InfoPath中的命名空间
  8. Python最实用的25个小技巧
  9. java box unboxing
  10. 通知:逆天异常库 V1.0版本支持下载了~~
  11. bootstrap入门之Code代码显示
  12. ArcGIS实验教程——实验四十三:ArcGIS栅格重分类(Reclass)案例详解
  13. 减速电机计算公式中功率(P),扭力(NM),转速(RPM),减速比(RATIO)四大因素互相转化的重要性
  14. linux中iptable和firewalld详解
  15. CPU、核心数、线程数、运行内存、超线程理解
  16. 【机器学习】损失函数MAE
  17. iOS之HomeKit
  18. python怎么画卡通人物_Python绘制可爱的卡通人物 | 【turtle使用】
  19. [野史乱弹]对一段历史的大胆臆测与还原 [暴笑转载]
  20. Unity高频面试题总结

热门文章

  1. 市场营销学python有用吗_1、熟悉Python编辑、开发和运行环境。
  2. 05定制后台和修改模型
  3. SegICP:一种集成深度语义分割和位姿估计的框架(附代码)
  4. CV技术在医疗领域中有哪些应用?Salesforce、谷歌、斯坦福综述文章登上Nature子刊...
  5. ORB-SLAM3 Initializer.cpp函数解读
  6. 项目需求|10~15万|自动上料系统—将物料通过机械手臂挂在挂钩上
  7. oracle 回收碎片,Oracle10g中表的碎片空间回收
  8. mysql 乐观锁 命令_MySQL-乐观锁
  9. Ecplise 恢复刚刚删除的文件
  10. CSS中列表样式的简介