pairs() 类变量图
我想知道是否可以使用对图(或此类函数ggplot
)来绘制类变量对,例如
#make some example data
dd<-data.frame(matrix(rnorm(108),36,2),c(rep("A",24),rep("B",24),rep("C",24)))
colnames(dd) <- c("Predicted_value", "Actual_value", "State_CD")
我想绘制 State_CD A vs B、A vs C 和 B vs C仅适用于预测值或实际值,或者可能两者都在同一绘图上。
我有 70 个类变量,而不是本示例中的 3 个,因此不想更改为宽格式。我更愿意将它们绘制为类变量并保留它们的名称,例如本例中的 A、B、C。
I am wondering if it is possible to use pair plot (or such function ggplot
) to plot pairs of a class variable, e.g.
#make some example data
dd<-data.frame(matrix(rnorm(108),36,2),c(rep("A",24),rep("B",24),rep("C",24)))
colnames(dd) <- c("Predicted_value", "Actual_value", "State_CD")
I want to plot State_CD A vs B, A vs C and B vs C either just for Predicted_value or Actual-value or may be both on same plot.
I have 70 class variables instead of 3 in this example, and so don't want to change to wide format. I'd prefer if I could plot them as class variable and keep their names such as A, B, C in this example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不太确定为什么你需要在这里成对。小倍数方法怎么样:
通读问题,如果您有 72 个组,您将需要进行某种汇总操作并使用不同类型的绘图。均值的点图非常适合此
点图:
I'm not really sure why you need pairs here. What about a small multiples approach:
Reading through the question, if you've got 72 groups you're going to need to do some sort of summary operation and use a different type of plot. A dotplot of the means would be great for this
Dotplot:
这不使用 ggplot 但你可以这样做:
这根本不是一个优雅的解决方案,但它应该为你工作...
This doesn't use ggplot but you can do something like this:
This is not at all an elegant solution but it should work for you...