采样后如何删除 R 热图中未采样的数据?
以下代码生成热图,但在 y 轴上显示原始数据集(采样前)中包含的所有 194 个国家/地区的标签。即使我删除原始数据集,这种情况仍然会发生。我还尝试关闭控制台以启动新会话,但无济于事。
qlife.s <- myData[sample(194,size=10,replace=F),]
qlife.s.m <- melt(qlife.s)
qlife.s.m <- ddply(qlife.s.m, .(variable), transform, rescale=rescale(value))
(p <- ggplot(qlife.s.m, aes(variable, qlife.s.m$Country))
+ geom_tile( aes(fill = rescale),
colour = "white")
+ scale_fill_gradient(low = "red", high = "green")
)
非常感谢任何建议。提前致谢。
The following code produces a heatmap but shows labels on the y axis for all 194 countries included in the original dataset (before sampling). This continues to happen even if I remove the original dataset. I've also tried shutting down the console to start a new session, to no avail.
qlife.s <- myData[sample(194,size=10,replace=F),]
qlife.s.m <- melt(qlife.s)
qlife.s.m <- ddply(qlife.s.m, .(variable), transform, rescale=rescale(value))
(p <- ggplot(qlife.s.m, aes(variable, qlife.s.m$Country))
+ geom_tile( aes(fill = rescale),
colour = "white")
+ scale_fill_gradient(low = "red", high = "green")
)
Any advice is much appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对您的数据使用
droplevels()
。从表面上看:应该做你想做的事,但如果没有可重现的例子就很难说。
Use
droplevels()
on your data. By the looks of things:should do what you want, but it is difficult to tell without a reproducible example.