仅输出r中标题中某些数据列的非空内容?
我有一个动态输出的图的标题,每次我们使用设置的预定义组合过滤数据时会更改。标题应该显示一些粘贴到来自加载该设置的excel文件的数据列的内容的字符串。我的问题。是有些列是空心的。
filters<-readxl("settings1.xlsx") {settings1 is defined as follows:manufacturer=audi,model="",displ=1.8,year=1999)
data<-mpg
ggplot(filtrated data, aes(x = displ, y = cty)) +
geom_point(size = 7, colour = "#EF783D", shape = 17) +
geom_line(color = "#EF783D") +
ggtitle(paste0("Insights :"," ",paste0(filters$manufacturer,filters$model,filters$displ,filters$year,collapse = ",")))
i have a title of dynamically outputed plots which change every time we filter the data using predefined combinations of settings .The title is supposed to show some string pasted to the contents of the columns of data coming from loading that excel file of settings.My problem is that some columns are left empty intentionnaly.The title is nice but showing also NA and i want to get rid of that .Code below.
filters<-readxl("settings1.xlsx") {settings1 is defined as follows:manufacturer=audi,model="",displ=1.8,year=1999)
data<-mpg
ggplot(filtrated data, aes(x = displ, y = cty)) +
geom_point(size = 7, colour = "#EF783D", shape = 17) +
geom_line(color = "#EF783D") +
ggtitle(paste0("Insights :"," ",paste0(filters$manufacturer,filters$model,filters$displ,filters$year,collapse = ",")))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于
过滤器
dataFrame具有缺少值或空值的列,因此距离我已经了解了您的问题,远离我已经了解了您的问题na
出现在图标题中。因此,要删除它,我试图通过更改过滤器
数据框架来解决它。由 reprex软件包(v2.0.1)
So far from what I have understood your problem since the
filters
dataframe has a column with missing value or empty value, supposemodel
hasNA
value, andNA
appears in the plot title. So to remove it, I have tried to solve it by changing thefilters
data frame a bit.Created on 2022-07-10 by the reprex package (v2.0.1)
您的代码不可复制,但这应该做:
Your code is non-reproducible, but this should do: