ggplot中带有Hmisc标签的对象的问题 [英] problems with Hmisc-labelled objects in ggplot

查看:66
本文介绍了ggplot中带有Hmisc标签的对象的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到消息

错误:没有适用于'round_any'的对象的适用方法 类已标记"

Error:no applicable method for 'round_any' applied to an object of class "labelled"

当我尝试使用ggplot2和R绘制图形时,我已经使用Hmisc::label在数据框中标记了变量,我认为这就是问题所在.我该如何解决这个问题?

when I try to plot my graphs using ggplot2 and R. I have labelled my variables in my data frame using Hmisc::label and I think this is the problem. How do I solve this issue?

我的标签如下:

   label(data$results_lp)="Lumbure Puncture Results"
   label(data$hiv_test)="HIV Test done"
   label(data$outcome)="Outcome at Discharge"
   label(data$vac_10mnth_complete)="Vaccinne 10months complete"
   label(data$vac_3mnth_complete)="Vaccine 3months complete"
   label(data$vac_uptodate)="Vaccine up to date"
   label(data$dx1_pneum_rcd)="Pneumonia Recorded"
   label(data$mal)="Malaria"
   label(data$dx1_malaria)="Documented Malaria"
   label(data$dehydrat)="Dehydration"

我该如何解决?

推荐答案

删除要打印的标签:

library(Hmisc)

DF <- data.frame(x=factor(rep(1:2,5)),y=1:10)

label(DF$x)="xLab"
label(DF$y)="yLab"

library(ggplot2)

ggplot(DF,aes(x=x,y=y)) + geom_boxplot()
#Don't know how to automatically pick scale for object of type labelled. Defaulting to continuous

ggplot(DF,aes(x=factor(unclass(x)),y=unclass(y))) + geom_boxplot()
#no warning

不幸的是,您没有提供重现错误和提供定制解决方案所需的详细信息.

Unfortunately you don't give the details necessary to reproduce your error and give a customized solution.

这篇关于ggplot中带有Hmisc标签的对象的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆