r - Partially suppress labels in R
问题描述
I am working with the R programming language. I am trying to plot "Decision Trees" using the "rpart.plot" library as shown below:
#load libraries
library(rpart)
library(rpart.plot)
#load data
data(iris)
#fit rpart model (i.e. decision tree)
r = rpart(Species ~., data=iris)
#plot model
rpart.plot(r)
I have noticed that sometimes the labels in this picture will say "iris$Petal.Length" and sometimes they will just say "Petal.Length".
Question: Is there a way to "suppress" these labels and always show the labels without the name of the dataset and the "$" symbol? I.e. Is it always possible to show the labels as only "Petal.Length" ? (So that they always look like the image I have posted)
Thanks
解决方案
you may define the model like this:
r = rpart(iris$Species ~iris$Petal.Length)
in this case, you'll see the dataset name in the labels
always try to use your dataset in the rpart() function like this:
r = rpart(Species ~., data=iris)
推荐阅读
- hive - 在 HiveQL 中将序列号转换为字母
- c# - 应用程序 C# 图像质量
- octave - 为什么 Octave 会在我的文件中插入这个奇怪的字符?
- markdown - Markdown - 带有数字和空格的锚点
- python - 尝试抓取以下网站时 csv 文件中的格式问题
- java - Java Android Runtime.getRuntime().exec()
- cross-platform - WSL 上的 Uno 平台:未更改模板中的错误
- javascript - 如何解决函数中的 no-param-reassign 错误
- c# - 如何在 ASP Dropdownlist ListItems 中使用彩色圆圈?(没有 jQuery)
- python - 如何在 Python 中使用 SSH 连接从远程主机发送 HTTP GET 请求?