带有 R 的基本 hexbin?
我有一项调查的结果。我正在尝试创建一个显示两个变量关系的图形:“Q1”和“Q9.1”。 “Q1”是独立的,“Q9.1”是从属的。这两个变量都有类似规模问题的答案:-2、-1、0、1、2。典型的情节将答案放在一起 - 不是很有趣或信息丰富。我认为 hexbin 是最好的选择。数据以 lpp 为单位。 我无法将“Q1”和“Q9.1”用于 x 和 y。但是:
> is.numeric("Q1")
[1] FALSE
q1.num <- as.numeric("Q1")
Warning message:
NAs introduced by coercion
Q1 的值为(数百个实例): -2,-1,0,1,2
如何使用此数据制作十六进制图? 我还应该考虑其他图表吗?
到目前为止的错误消息:
Warning messages:
1: In xy.coords(x, y, xl, yl) : NAs introduced by coercion
2: In xy.coords(x, y, xl, yl) : NAs introduced by coercion
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf
I have results from a survey. I am trying to create a graphic displaying the relationship of two variables: "Q1" and "Q9.1". "Q1" is the independent and "Q9.1" is the dependent. Both variables have responses from like scale questions: -2,-1,0,1,2. A typical plot places the answers on top of each other - not very interesting or informative. I was thinking that hexbin would be the way to go. The data is in lpp.
I have not been able to use "Q1" and "Q9.1" for x and y. However:
> is.numeric("Q1")
[1] FALSE
q1.num <- as.numeric("Q1")
Warning message:
NAs introduced by coercion
The values for Q1 are (hundreds of instances of): -2,-1,0,1,2
How can I make a hexbin graph with this data?
Is there another graph I should consider?
Error messages so far:
Warning messages:
1: In xy.coords(x, y, xl, yl) : NAs introduced by coercion
2: In xy.coords(x, y, xl, yl) : NAs introduced by coercion
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
采取稍微不同的方法怎么样?将您的回答视为因素而不是数字怎么样?然后,您可以使用类似的方法来获取数据的潜在有用表示:
您可能希望根据所需数据的视图切换上面的 q1 和 q9。
How about taking a slightly different approach? How about thinking of your responses as factors rather than numbers? You could use something like this, then, to get a potentially useful representation of your data:
You may want to switch q1 and q9 above, depending on the view of the data that you want.
也许 ggplot2 的 stat_binhex 可以为您排序?
另外,我发现 scale_alpha 对于处理过度绘图很有用。
Perhaps ggplot2's stat_binhex could sort that one for you?
Also, I find scale_alpha useful for dealing with overplotting.